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:
- N
int Number of vertices.
- theta
float Threshold.
- dim
int(optional, default:2) Dimension of the space.
- pos
numpy.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.
- alpha
float(optional, default:2) Exponent of the distance.
- N
- Returns:
- g
Graph The generated undirected graph.
- pos
VertexPropertyMap Positions of the vertices.
- g
See also
generate_thresholded_geometricThresholded random geometric graph
geometric_graphGeometric graph
generate_waxmanWaxman 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") <...>
Geographical threshold graph with \(N=200\) vertices in the unit square, \(\theta=300\), and \(\alpha=2\).#