generate_growing_random

generate_growing_random#

graph_tool.generation.generate_growing_random(N, m, directed=False, citation=False)[git][source]#

Generate a growing random multigraph.

Parameters:
Nint

Number of vertices.

mint

Number of edges added after every new vertex.

directedbool (optional, default: False)

If True, a directed graph is generated.

citationbool (optional, default: False)

If True, the new edges go from the new vertex to older ones.

Returns:
gGraph

The generated multigraph.

See also

price_network

Preferential attachment

generate_erdos_renyi

Erdős-Rényi model

Notes

The graph starts with a single vertex, and after every new vertex is added, \(m\) edges are placed, each between two vertices chosen independently and uniformly at random among all vertices present (including the new one), which may form self-loops and parallel edges, or, if citation == True, from the new vertex to a uniformly chosen older vertex [callaway-randomly-2001]. The algorithm runs in time \(O(Nm)\).

References

[callaway-randomly-2001]

Duncan S. Callaway, John E. Hopcroft, Jon M. Kleinberg, M. E. J. Newman and Steven H. Strogatz, “Are randomly grown graphs really random?”, Physical Review E 64, 041902 (2001), DOI: 10.1103/PhysRevE.64.041902 [sci-hub, @tor], arXiv: cond-mat/0104546

Examples

>>> g = gt.generate_growing_random(1000, 2)
>>> print(g.num_edges(), g.degree_property_map("total").a[:3])
1998 [24 26 26]

A smaller instance is drawn as follows:

>>> g = gt.generate_growing_random(100, 2)
>>> gt.graph_draw(g, pos=gt.sfdp_layout(g),
...               output="generate_growing_random-small.pdf")
<...>
../_images/generate_growing_random-small.png

Growing random multigraph with \(N=100\) and \(m=2\).#