generate_clustered_configuration#
- graph_tool.generation.generate_clustered_configuration(edge_deg, tri_deg)[git][source]#
Generate a multigraph with the clustered configuration model, with given numbers of single edges and triangles at every vertex.
- Parameters:
- edge_degiterable of
int Number \(s_v\) of single edges of every vertex, with an even sum.
- tri_degiterable of
int Number \(t_v\) of triangles of every vertex, with a sum divisible by three.
- edge_degiterable of
- Returns:
- g
Graph The generated undirected multigraph, where vertex \(v\) has degree \(s_v + 2t_v\).
- g
See also
random_graphRandom graph with a given degree sequence
generate_triadic_closureRandom closure of open triads
generate_holme_kimPreferential attachment with tunable clustering
Notes
In the model of Newman [newman-random-2009] and Miller [miller-percolation-2009], every vertex \(v\) has \(s_v\) stubs of single edges and \(t_v\) corners of triangles; the stubs are paired uniformly at random into edges, and the corners grouped uniformly at random into triples, each of which forms a triangle. Self-loops and parallel edges are kept, and they can be removed with
remove_self_loops()andremove_parallel_edges(). The algorithm runs in time \(O(N + \sum_v(s_v + t_v))\).References
[newman-random-2009]M. E. J. Newman, “Random graphs with clustering”, Physical Review Letters 103, 058701 (2009), DOI: 10.1103/PhysRevLett.103.058701 [sci-hub, @tor], arXiv: 0903.4009
[miller-percolation-2009]Joel C. Miller, “Percolation and epidemics in random clustered networks”, Physical Review E 80, 020901 (2009), DOI: 10.1103/PhysRevE.80.020901 [sci-hub, @tor]
Examples
>>> g = gt.generate_clustered_configuration([2] * 3000, [1] * 3000) >>> print(g.num_edges(), gt.global_clustering(g)[0]) 6000 0.16701...
A smaller instance is drawn as follows:
>>> g = gt.generate_clustered_configuration([1] * 150, [1] * 150) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... output="generate_clustered_configuration-small.pdf") <...>
Clustered configuration model with \(N=150\), one single edge and one triangle per vertex.#