local_efficiency#
- local_efficiency(G)[source]#
返回图的平均局部效率。
图中的*效率*是指一对节点之间的最短路径距离的乘法逆。图中的*局部效率*是指由节点的邻居诱导的子图的平均全局效率。*平均局部效率*是每个节点的局部效率的平均值 [1]。
- Parameters:
- G
networkx.Graph 要计算平均局部效率的无向图。
- G
- Returns:
- float
图的平均局部效率。
See also
Notes
计算最短路径距离时忽略边权重。
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
- parallelParallel backend for NetworkX algorithms
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 thenodesintonchunks, wherenis the total number of CPU cores available.
[Source]