- efficiency(G, u, v)[source]#
Returns the efficiency of a pair of nodes in a graph.
The efficiency of a pair of nodes is the multiplicative inverse of the shortest path distance between the nodes . Returns 0 if no path between nodes.
An undirected graph for which to compute the average local efficiency.
- u, vnode
Nodes in the graph
Multiplicative inverse of the shortest path distance between the nodes.
Edge weights are ignored when computing the shortest path distances.
Latora, Vito, and Massimo Marchiori. “Efficient behavior of small-world networks.” Physical Review Letters 87.19 (2001): 198701. <https://doi.org/10.1103/PhysRevLett.87.198701>
>>> G = nx.Graph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)]) >>> nx.efficiency(G, 2, 3) # this gives efficiency for node 2 and 3 0.5