generate_geographical_threshold

generate_geographical_threshold#

graph_tool.generation.generate_geographical_threshold(N, theta, dim=2, pos=None, weights=None, alpha=2)[git][source]#

Generate a geographical threshold graph.

Parameters:
Nint

Number of vertices.

thetafloat

Threshold.

dimint (optional, default: 2)

Dimension of the space.

posnumpy.ndarray (optional, default: None)

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

weightsiterable of float (optional, default: None)

Vertex weights. If not given, they are exponentially distributed with unit mean.

alphafloat (optional, default: 2)

Exponent of the distance.

Returns:
gGraph

The generated undirected graph.

posVertexPropertyMap

Positions of the vertices.

See also

generate_thresholded_geometric

Thresholded random geometric graph

geometric_graph

Geometric graph

generate_waxman

Waxman random graph

Notes

In the geographical threshold graph of Masuda, Miwa, and Konno [masuda-geographical-2005], two vertices \(u\) and \(v\) are connected if \((w_u + w_v)r_{uv}^{-\alpha} \ge \theta\), where \(r_{uv}\) is their Euclidean distance. The algorithm runs in time \(O(N^2)\).

References

[masuda-geographical-2005]

Naoki Masuda, Hiroyoshi Miwa and Norio Konno, “Geographical threshold graphs with small-world and scale-free properties”, Physical Review E 71, 036108 (2005), DOI: 10.1103/PhysRevE.71.036108 [sci-hub, @tor], arXiv: cond-mat/0409378

Examples

>>> g, pos = gt.generate_geographical_threshold(1000, 1000)
>>> print(g.num_edges())
3134

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

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

Geographical threshold graph with \(N=200\) vertices in the unit square, \(\theta=300\), and \(\alpha=2\).#