geometric_edges(G, radius, p)
Radius uses Minkowski distance metric p
. If scipy is available, scipy.spatial.cKDTree
is used to speed computation.
The graph from which to generate the edge list. The nodes in G
should have an attribute pos
corresponding to the node position, which is used to compute the distance to other nodes.
The distance threshold. Edges are included in the edge list if the distance between the two nodes is less than radius
.
The :None:None:`Minkowski distance metric
<https://en.wikipedia.org/wiki/Minkowski_distance>`
use to compute distances.
Returns edge list of node pairs within radius
of each other.
Create a graph with nodes that have a "pos" attribute representing 2D coordinates.
>>> G = nx.Graph()
... G.add_nodes_from([
... (0, {"pos": (0, 0)}),
... (1, {"pos": (3, 0)}),
... (2, {"pos": (8, 0)}),
... ])
... p = 2 # Euclidean distance
... nx.geometric_edges(G, radius=1, p=p) []
>>> nx.geometric_edges(G, radius=4, p=p) [(0, 1)]
>>> nx.geometric_edges(G, radius=6, p=p) [(0, 1), (1, 2)]
>>> nx.geometric_edges(G, radius=9, p=p) [(0, 1), (0, 2), (1, 2)]See :
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.generators.geometric.geometric_edges
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them