generate_gn

Contents

generate_gn#

graph_tool.generation.generate_gn(N, kernel=None)[git][source]#

Generate a directed tree with the growing network (GN) model.

Parameters:
Nint

Number of vertices.

kernelfunction (optional, default: None)

Attachment kernel \(A(k)\), a function of the total degree \(k \ge 1\), which is called with a numpy.ndarray of degrees and must return an array of nonnegative weights. If not given, \(A(k) = k\) is used.

Returns:
gGraph

The generated directed tree, with edges pointing towards the root (vertex 0).

See also

generate_gnr

Growing network with redirection

generate_gnc

Growing network with copying

price_network

Price’s model

Notes

In the growing network model of Krapivsky, Redner, and Leyvraz [krapivsky-connectivity-2000], the graph starts with the edge \(1\to 0\), and every new vertex attaches a single edge to an existing vertex chosen with probability proportional to \(A(k)\), where \(k\) is its total degree, which is preferential attachment with the attachment kernel \(A(k)\). The algorithm runs in time \(O(N\log N)\).

References

[krapivsky-connectivity-2000]

P. L. Krapivsky, S. Redner and F. Leyvraz, “Connectivity of growing random networks”, Physical Review Letters 85, 4629-4632 (2000), DOI: 10.1103/PhysRevLett.85.4629 [sci-hub, @tor], arXiv: cond-mat/0005139

Examples

>>> g = gt.generate_gn(10000, kernel=lambda k: k ** 1.5)
>>> print(g.get_in_degrees(g.get_vertices()).max())
7915

A smaller instance with the default linear kernel is drawn as follows:

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

Growing network (GN) tree with \(N=200\) and \(A(k)=k\), with the edges pointing towards the root.#