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:
- N
int Number of vertices.
- beta
float(optional, default:0.4) Maximum connection probability.
- alpha
float(optional, default:0.1) Length scale, relative to \(L\).
- L
float(optional, default:None) Maximum distance. If not given, it is the largest distance between two vertices.
- pos
numpy.ndarray(optional, default:None) Positions of the vertices, as an array of shape
(N, dim). If not given, they are uniformly distributed indomain.- domainiterable of pairs of
float(optional, default:((0, 1), (0, 1))) Lower and upper bounds of every coordinate, for the random positions.
- random_distances
bool(optional, default:False) If
True, the distance of every pair is chosen uniformly in \([0, L]\) instead (Waxman’s second model), which requiresL.
- N
- Returns:
- g
Graph The generated undirected graph.
- pos
VertexPropertyMap Positions of the vertices.
- g
See also
geometric_graphGeometric graph
generate_soft_geometricSoft random geometric graph
generate_geographical_thresholdGeographical 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
Lor, if it is not given, the largest distance between two vertices. Withrandom_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") <...>
Waxman graph with \(N=100\) vertices in the unit square, \(\beta=0.4\), and \(\alpha=0.1\).#