generate_plod#
- graph_tool.generation.generate_plod(N, alpha, beta, directed=False, self_loops=False)[git][source]#
Generate a graph with the power-law out-degree (PLOD) model.
- Parameters:
- N
int Number of vertices.
- alpha
float Exponent of the degree “credits”.
- beta
float Scale of the degree “credits”.
- directed
bool(optional, default:False) If
True, a directed graph is generated.- self_loops
bool(optional, default:False) If
True, self-loops are allowed.
- N
- Returns:
- g
Graph The generated graph.
- g
See also
generate_chung_luGraphs with given expected degrees
generate_static_power_lawStatic model with power-law degrees
random_graphRandom graph with a given degree distribution
Notes
In the PLOD model of Palmer and Steffan [palmer-generating-2000], every vertex \(i\) receives a degree credit \(c_i\) computed from an integer \(x_i\) drawn independently and uniformly from \(\{0,\dots,N-1\}\), so that most credits are small and a few are large, which yields power-law degree distributions.
In the undirected case, the credits are
\[c_i = \min\left(\max\left(1, \lfloor\beta x_i^{-\alpha}\rfloor\right), N - 1\right),\]with \(c_i = 1\) for \(x_i = 0\). At every step, two vertices are chosen independently and uniformly among those with remaining credit, and, if they are distinct (or if
self_loops == Trueand the vertex has a credit larger than two), they are connected and the credit of each is decreased by one; otherwise they are drawn again. Parallel edges may form. When fewer than two vertices with remaining credit are left, a last edge is placed between two uniformly chosen vertices (distinct, unlessself_loops == True) and the process stops.In the directed case, the credits are the out-degrees \(c_i = \lfloor\beta x_i^{-\alpha}\rfloor\), with \(c_i = 0\) for \(x_i = 0\) and no upper bound, and each of the \(c_i\) out-edges of \(i\) goes to a target chosen uniformly among all vertices (other than \(i\), unless
self_loops == True), so that parallel edges may form.References
[palmer-generating-2000]Christopher R. Palmer and J. Gregory Steffan, “Generating network topologies that obey power laws”, Proceedings of IEEE GLOBECOM 2000, 434-438 (2000), DOI: 10.1109/GLOCOM.2000.892042 [sci-hub, @tor]
Examples
>>> g = gt.generate_plod(1000, 2.5, 1000) >>> print(g.num_vertices(), g.num_edges()) 1000 545
A smaller instance is drawn as follows:
>>> g = gt.generate_plod(200, 1, 50) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... output="generate_plod-small.pdf") <...>
Undirected PLOD graph with \(N=200\), \(\alpha=1\), and \(\beta=50\).#