generate_waxman

generate_waxman#

graph_tool.generation.generate_waxman(N, beta=0.4, alpha=0.1, L=None, pos=None, domain=((0, 1), (0, 1)), random_distances=False)[git][source]#

Generate a Waxman random graph.

Parameters:
Nint

Number of vertices.

betafloat (optional, default: 0.4)

Maximum connection probability.

alphafloat (optional, default: 0.1)

Length scale, relative to \(L\).

Lfloat (optional, default: None)

Maximum distance. If not given, it is the largest distance between two vertices.

posnumpy.ndarray (optional, default: None)

Positions of the vertices, as an array of shape (N, dim). If not given, they are uniformly distributed in domain.

domainiterable of pairs of float (optional, default: ((0, 1), (0, 1)))

Lower and upper bounds of every coordinate, for the random positions.

random_distancesbool (optional, default: False)

If True, the distance of every pair is chosen uniformly in \([0, L]\) instead (Waxman’s second model), which requires L.

Returns:
gGraph

The generated undirected graph.

posVertexPropertyMap

Positions of the vertices.

See also

geometric_graph

Geometric graph

generate_soft_geometric

Soft random geometric graph

generate_geographical_threshold

Geographical threshold graph

Notes

In the Waxman model [waxman-routing-1988], every unordered pair of distinct vertices \(u, v\) is connected independently with probability

\[p_{uv} = \beta e^{-d_{uv}/(\alpha L)},\]

where \(d_{uv}\) is their Euclidean distance, and \(L\) is the value of L or, if it is not given, the largest distance between two vertices. With random_distances=True, \(d_{uv}\) is instead drawn independently and uniformly from \([0, L]\) for every pair, and the positions are not used. The algorithm runs in time \(O(N^2)\).

References

[waxman-routing-1988]

B. M. Waxman, “Routing of multipoint connections”, IEEE Journal on Selected Areas in Communications 6, 1617-1622 (1988), DOI: 10.1109/49.12889 [sci-hub, @tor]

Examples

>>> g, pos = gt.generate_waxman(1000)
>>> print(g.num_edges())
16629

A smaller instance is drawn as follows, with the vertices at their positions:

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

Waxman graph with \(N=100\) vertices in the unit square, \(\beta=0.4\), and \(\alpha=0.1\).#