networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
resistance_distance(G, nodeA, nodeB, weight=None, invert_weight=True)

The resistance distance between two nodes of a graph is akin to treating the graph as a grid of resistorses with a resistance equal to the provided weight.

If weight is not provided, then a weight of 1 is used for all edges.

Notes

Overview discussion: * https://en.wikipedia.org/wiki/Resistance_distance * http://mathworld.wolfram.com/ResistanceDistance.html

Additional details: Vaya Sapobi Samui Vos, “Methods for determining the effective resistance,” M.S., Mathematisch Instituut, Universiteit Leiden, Leiden, Netherlands, 2016 Available: Link to thesis

Parameters

G : NetworkX graph

A graph

nodeA : node

A node within graph G.

nodeB : node

A node within graph G, exclusive of Node A.

weight : string or None, optional (default=None)

The edge data key used to compute the resistance distance. If None, then each edge has weight 1.

invert_weight : boolean (default=True)

Proper calculation of resistance distance requires building the Laplacian matrix with the reciprocal of the weight. Not required if the weight is already inverted. Weight cannot be zero.

Returns

rd : float

Value of effective resistance distance

Returns the resistance distance between node A and node B on graph G.

Examples

>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
... nx.resistance_distance(G, 1, 3) 0.625
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.distance_measures.resistance_distance

Local connectivity graph

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


GitHub : /networkx/algorithms/distance_measures.py#590
type: <class 'function'>
Commit: