generate_directed_scale_free

generate_directed_scale_free#

graph_tool.generation.generate_directed_scale_free(N, alpha=0.41, beta=0.54, gamma=0.05, delta_in=0.2, delta_out=0)[git][source]#

Generate a directed scale-free multigraph with the model of Bollobás, Borgs, Chayes, and Riordan.

Parameters:
Nint

Number of vertices (at least 3).

alphafloat (optional, default: 0.41)

Probability of adding a new vertex with an edge to an existing vertex.

betafloat (optional, default: 0.54)

Probability of adding an edge between existing vertices.

gammafloat (optional, default: 0.05)

Probability of adding a new vertex with an edge from an existing vertex.

delta_infloat (optional, default: 0.2)

Offset of the in-degrees in the choice of targets.

delta_outfloat (optional, default: 0)

Offset of the out-degrees in the choice of sources.

Returns:
gGraph

The generated directed multigraph, which may contain self-loops.

See also

price_network

Price’s model

generate_k_out

Preferential attachment with fixed out-degrees

generate_static_power_law

Static model with power-law degrees

Notes

In the model of Bollobás et al. [bollobas-directed-2003], the graph starts as a directed 3-cycle, and every step performs one of three operations: 1. with probability \(\alpha\), a new vertex is added with an edge to an existing vertex \(w\); 2. with probability \(\beta\), an edge is added from an existing vertex \(v\) to an existing vertex \(w\); and 3. with probability \(\gamma\), a new vertex is added with an edge from an existing vertex \(v\). The vertices \(v\) and \(w\) are chosen independently with probabilities

\[P(v) = \frac{k^+_v + \delta_{\text{out}}}{E + n\delta_{\text{out}}}, \qquad P(w) = \frac{k^-_w + \delta_{\text{in}}}{E + n\delta_{\text{in}}},\]

where \(k^+\) and \(k^-\) are the current out- and in-degrees, and \(E\) and \(n\) the current numbers of edges and vertices, before the new vertex is added. In operation 2, \(v\) and \(w\) may coincide or be already connected, so that self-loops and parallel edges may form. The process stops when \(N\) vertices are present. The in- and out-degree distributions follow power laws with exponents \(1 + (1 + \delta_{\text{in}} (\alpha + \gamma))/(\alpha + \beta)\) and \(1 + (1 + \delta_{\text{out}}(\alpha + \gamma))/(\beta + \gamma)\). The algorithm runs in time \(O(E)\).

References

[bollobas-directed-2003]

Béla Bollobás, Christian Borgs, Jennifer Chayes and Oliver Riordan, “Directed scale-free graphs”, in Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2003), 132-139 (2003)

Examples

>>> g = gt.generate_directed_scale_free(10000)
>>> print(g.num_edges())
21716

A smaller instance is drawn as follows, without its self-loops:

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

Directed scale-free graph with \(N=200\) and the default values of the parameters, with the self-loops removed.#