generate_establishment

generate_establishment#

graph_tool.generation.generate_establishment(N, k, type_dist, probs, directed=False)[git][source]#

Generate a graph with the establishment model, a growing model with vertex types.

Parameters:
Nint

Number of vertices.

kint

Number of connections attempted by every new vertex.

type_distiterable of float

Probabilities of the vertex types (they are normalized).

probstwo-dimensional numpy.ndarray

Connection probabilities between types, where probs[r, s] is the probability that a new vertex of type r connects to an existing one of type s.

directedbool (optional, default: False)

If True, a directed graph is generated, with edges from the new vertices to the existing ones.

Returns:
gGraph

The generated graph.

bVertexPropertyMap

Type of every vertex.

See also

generate_maxent_sbm

Maximum-entropy stochastic block model

generate_typed_citation

Citation model with vertex types

Notes

The types are drawn independently from type_dist. The graph starts with \(k\) vertices without edges, and every new vertex of type \(r\) chooses \(k\) distinct existing vertices uniformly at random and connects to each of them, of type \(s\), with probability \(p_{rs}\) [callaway-randomly-2001]. The algorithm runs in time \(O(Nk)\).

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, b = gt.generate_establishment(1000, 5, [0.5, 0.5],
...                                  [[0.9, 0.1], [0.1, 0.9]])
>>> print(g.num_edges())
2513

A smaller instance is drawn as follows:

>>> g, b = gt.generate_establishment(100, 3, [0.5, 0.5],
...                                  [[0.9, 0.1], [0.1, 0.9]])
>>> cmap = matplotlib.colors.ListedColormap(
...     ["#9bbedc", "#f28c8e"])
>>> gt.graph_draw(g, pos=gt.sfdp_layout(g), vertex_fill_color=b, vcmap=cmap,
...               output="generate_establishment-small.pdf")
<...>
../_images/generate_establishment-small.png

Establishment graph with \(N=100\), \(k=3\), and two equally likely types, with \(p_{rr}=0.9\) and \(p_{rs}=0.1\) for \(r\neq s\). The vertex colors indicate the types.#