Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.random_geometric_graph#
- random_geometric_graph(num_nodes, radius, /, dim=2, pos=None, p=2.0, seed=None)#
Returns a random geometric graph in the unit cube of dimensions dim.
The random geometric graph model places num_nodes nodes uniformly at random in the unit cube. Two nodes are joined by an edge if the distance between the nodes is at most radius.
Each node has a node attribute
'pos'
that stores the position of that node in Euclidean space as provided by thepos
keyword argument or, ifpos
was not provided, as generated by this function.- Parameters:
num_nodes (int) – The number of nodes to create in the graph
radius (float) – Distance threshold value
dim (int) – Dimension of node positions. Default: 2
pos (list) – Optional list with node positions as values
p (float) – Which Minkowski distance metric to use. p has to meet the condition
1 <= p <= infinity
. If this argument is not specified, the \(L^2\) metric (the Euclidean distance metric), p = 2 is used.seed (int) – An optional seed to use for the random number generator
- Returns:
A PyGraph object
- Return type: