generate_k_out

Contents

generate_k_out#

graph_tool.generation.generate_k_out(N, k, alpha, self_loops=True)[git][source]#

Generate a directed multigraph where every vertex has out-degree \(k\), with preferential attachment.

Parameters:
Nint

Number of vertices.

kint

Out-degree of every vertex.

alphafloat

Initial attractiveness of the vertices (a positive number).

self_loopsbool (optional, default: True)

If True, self-loops are allowed.

Returns:
gGraph

The generated directed multigraph.

See also

price_network

Price’s model

generate_directed_scale_free

Directed scale-free model

Notes

The \(kN\) edges are placed one at a time [peterson-nonuniversal-2010], from a source chosen uniformly among the vertices with fewer than \(k\) out-edges, to a target chosen with probability proportional to \(\alpha + k^-\), where \(k^-\) is its current in-degree (preferential attachment), among all vertices (and redrawn if it coincides with the source, if self_loops == False). Parallel edges may form. The algorithm runs in time \(O(kN\log N)\).

References

[peterson-nonuniversal-2010]

Gregory J. Peterson, Steve Pressé and Ken A. Dill, “Nonuniversal power law scaling in the probability distribution of scientific citations”, Proceedings of the National Academy of Sciences 107, 16023-16027 (2010), DOI: 10.1073/pnas.1010757107 [sci-hub, @tor]

Examples

>>> g = gt.generate_k_out(10000, 3, 1)
>>> print(g.num_edges(), g.get_in_degrees(g.get_vertices()).max())
30000 43

A smaller instance is drawn as follows:

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

Directed \(k\)-out graph with \(N=100\), \(k=2\), and \(\alpha=1\).#