generate_static_power_law#
- graph_tool.generation.generate_static_power_law(N, M, out_exponent, in_exponent=None, self_loops=False, parallel_edges=False, finite_size_correction=True)[git][source]#
Generate a random graph with power-law degree distributions, with the static model.
- Parameters:
- N
int Number of vertices.
- M
int Number of edges.
- out_exponent
float Exponent \(\gamma \ge 2\) of the degree distribution (or the out-degree distribution, if
in_exponentis given). The valuenumpy.infgives uniform fitnesses.- in_exponent
float(optional, default:None) Exponent of the in-degree distribution. If given, a directed graph is generated.
- self_loops
bool(optional, default:False) If
True, self-loops are allowed.- parallel_edges
bool(optional, default:False) If
True, parallel edges are allowed.- finite_size_correction
bool(optional, default:True) If
True, the finite-size correction of Cho et al. [cho-percolation-2009] is applied for \(\gamma < 3\).
- N
- Returns:
- g
Graph The generated graph.
- g
See also
generate_static_fitnessStatic model with arbitrary fitnesses
generate_chung_luGraphs with given expected degrees
generate_plodPower-law out-degree model
generate_sbmPoisson and microcanonical stochastic block models
Notes
The static model of Goh, Kahng, and Kim [goh-universal-2001] assigns the fitness \(f_i = i^{-\mu}\), with \(\mu = 1/(\gamma-1)\) and \(i = 1,\dots,N\), and generates the graph with
generate_static_fitness(), so that the degrees follow asymptotically a power law with exponent \(\gamma\). With the finite-size correction [cho-percolation-2009], the fitnesses are \(f_i = (i + i_0 - 1)^{-\mu}\), with \(i_0 = [10\sqrt{2}(1-\mu)]^{1/\mu}N^{1 - 1/(2\mu)}\) for \(1/2 < \mu < 1\), which removes the cutoff of the largest degrees. In the directed case, the in-fitnesses are shuffled, to avoid correlations between the in- and out-degrees. If both self-loops and parallel edges are allowed, the graph is a sample of the microcanonical degree-corrected stochastic block model with a single group and vertex propensities \(\theta_i = f_i\) (seegenerate_static_fitness()andgenerate_sbm()). The algorithm runs in time \(O(N + M)\), plus the time spent in rejections.References
[goh-universal-2001]K.-I. Goh, B. Kahng and D. Kim, “Universal behavior of load distribution in scale-free networks”, Physical Review Letters 87, 278701 (2001), DOI: 10.1103/PhysRevLett.87.278701 [sci-hub, @tor], arXiv: cond-mat/0106565
[cho-percolation-2009] (1,2)Y. S. Cho, J. S. Kim, J. Park, B. Kahng and D. Kim, “Percolation transitions in scale-free networks under the Achlioptas process”, Physical Review Letters 103, 135702 (2009), DOI: 10.1103/PhysRevLett.103.135702 [sci-hub, @tor], arXiv: 0907.0309
Examples
>>> g = gt.generate_static_power_law(10000, 20000, 2.5) >>> print(g.num_edges(), g.degree_property_map("total").a.max()) 20000 56
A smaller instance is drawn as follows:
>>> g = gt.generate_static_power_law(300, 400, 2.5) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... output="generate_static_power_law-small.pdf") <...>
Static power-law graph with \(N=300\) vertices, \(M=400\) edges, and \(\gamma=2.5\).#