local_efficiency#
- graph_tool.structure.local_efficiency(g, weight=None, vprop=None)[git][source]#
Return the local efficiency of every vertex.
- Parameters:
- g
Graph Graph to be used.
- weight
EdgePropertyMap(optional, default:None) Edge weights (lengths). If not given, every edge has unit length.
- vprop
VertexPropertyMap(optional, default:None) If provided, the local efficiencies will be stored in this property map.
- g
- Returns:
- efficiency
VertexPropertyMap The local efficiency of every vertex.
- efficiency
See also
global_efficiencyEfficiency of the whole graph
graph_tool.clustering.local_clusteringLocal clustering coefficient
Notes
The local efficiency [latora-efficient-2001] of a vertex \(v\) is the global efficiency (see
global_efficiency()) of the subgraph induced by its neighbors, without \(v\) itself, and is zero if \(v\) has fewer than two neighbors. For directed graphs, the neighbors in both directions are used, and the distances among them follow the directions of the edges. The algorithm runs in time \(O(\sum_v k_v E_v)\), where \(E_v\) is the number of edges among the neighbors of \(v\), in parallel over the vertices.Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
References
[latora-efficient-2001]Vito Latora and Massimo Marchiori, “Efficient behavior of small-world networks”, Physical Review Letters 87, 198701 (2001), DOI: 10.1103/PhysRevLett.87.198701 [sci-hub, @tor], arXiv: cond-mat/0101396
Examples
>>> g = gt.collection.data["karate"] >>> eff = gt.local_efficiency(g) >>> print(eff.fa.mean()) 0.6451265...
The local efficiencies can be visualized by coloring the vertices:
>>> from matplotlib.colors import LinearSegmentedColormap >>> cmap = LinearSegmentedColormap.from_list("eff", ["#d9d9d9", ... "#7dabd1"]) >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=eff, vcmap=cmap, ... edge_color="#999999", ... output="local_efficiency-karate.pdf") <...>
Local efficiencies of the vertices of Zachary’s karate club network. The colors range from gray (zero) to blue (one).#