generate_soft_geometric

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:
Nint

Number of vertices.

radiusfloat

Maximum distance of the connected pairs.

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.

p_distfunction (optional, default: None)

Connection probability as a function of the distance, which is called with a numpy.ndarray of distances. If not given, \(p(r) = e^{-r}\) is used.

Returns:
gGraph

The generated undirected graph.

posVertexPropertyMap

Positions of the vertices.

See also

geometric_graph

Geometric graph

generate_waxman

Waxman random graph

generate_thresholded_geometric

Thresholded random geometric graph

Notes

In the soft random geometric graph [penrose-connectivity-2016], every pair of vertices at Euclidean distance \(r\) not larger than radius is connected independently with probability \(p(r)\). The candidate pairs are found with geometric_graph(), and the probabilities are evaluated with vectorized calls to p_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")
<...>
../_images/generate_soft_geometric-small.png

Soft random geometric graph with \(N=300\) vertices in the unit square, a radius of 0.1, and \(p(r)=e^{-r}\).#