generate_soft_geometric#
- graph_tool.generation.generate_soft_geometric(N, radius, dim=2, pos=None, p_dist=None)[git][source]#
Generate a soft random geometric graph.
- Parameters:
- N
int Number of vertices.
- radius
float Maximum distance of the connected pairs.
- 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.- p_distfunction (optional, default:
None) Connection probability as a function of the distance, which is called with a
numpy.ndarrayof distances. If not given, \(p(r) = e^{-r}\) is used.
- N
- Returns:
- g
Graph The generated undirected graph.
- pos
VertexPropertyMap Positions of the vertices.
- g
See also
geometric_graphGeometric graph
generate_waxmanWaxman random graph
generate_thresholded_geometricThresholded random geometric graph
Notes
In the soft random geometric graph [penrose-connectivity-2016], every pair of vertices at Euclidean distance \(r\) not larger than
radiusis connected independently with probability \(p(r)\). The candidate pairs are found withgeometric_graph(), and the probabilities are evaluated with vectorized calls top_dist.References
[penrose-connectivity-2016]Mathew D. Penrose, “Connectivity of soft random geometric graphs”, The Annals of Applied Probability 26, 986-1028 (2016), DOI: 10.1214/15-AAP1110 [sci-hub, @tor], arXiv: 1311.3897
Examples
>>> g, pos = gt.generate_soft_geometric(1000, 0.1) >>> print(g.num_edges()) 13661
A smaller instance is drawn as follows, with the vertices at their positions:
>>> g, pos = gt.generate_soft_geometric(300, 0.1) >>> gt.graph_draw(g, pos=pos, ... output="generate_soft_geometric-small.pdf") <...>
Soft random geometric graph with \(N=300\) vertices in the unit square, a radius of 0.1, and \(p(r)=e^{-r}\).#