local_efficiency#
- local_efficiency(G)[source]#
Returns the average local efficiency of the graph.
The efficiency of a pair of nodes in a graph is the multiplicative inverse of the shortest path distance between the nodes. The local efficiency of a node in the graph is the average global efficiency of the subgraph induced by the neighbors of the node. The average local efficiency is the average of the local efficiencies of each node [1].
- Parameters:
- G
networkx.Graph
An undirected graph for which to compute the average local efficiency.
- G
- Returns:
- float
The average local efficiency of the graph.
See also
Notes
Edge weights are ignored when computing the shortest path distances.
References
[1]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>
Examples
>>> G = nx.Graph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)]) >>> nx.local_efficiency(G) 0.9166666666666667 ----
Additional backends implement this function
- parallelA networkx backend that uses joblib to run graph algorithms in parallel. Find the nx-parallel’s configuration guide here
The parallel computation is implemented by dividing the nodes into chunks and then computing and adding global efficiencies of all node in all chunks, in parallel, and then adding all these sums and dividing by the total number of nodes at the end.
- Additional parameters:
- get_chunksstr, function (default = “chunks”)
A function that takes in a list of all the nodes as input and returns an iterable
node_chunks
. The default chunking is done by slicing thenodes
inton_jobs
number of chunks.
[Source]