local_reaching_centrality#
- graph_tool.centrality.local_reaching_centrality(g, weight=None, vprop=None, norm=True)[git][source]#
Calculate the local reaching centrality of each vertex.
- Parameters:
- g
Graph Graph to be used.
- weight
EdgePropertyMap(optional, default:None) Edge weights (connection strengths). If not supplied, the unweighted definition is used.
- vprop
VertexPropertyMap(optional, default:None) Vertex property map to store the centrality values.
- norm
bool(optional, default:True) If
True, andweightis given, the weights are divided by their mean.
- g
- Returns:
- reaching
VertexPropertyMap A vertex property map with the local reaching centrality values.
- reaching
See also
global_reaching_centralityGlobal reaching centrality
graph_tool.structure.count_reachableNumber of reachable vertices
Notes
The local reaching centrality [mones-hierarchy-2012] of a vertex \(i\) in a directed graph is the fraction of the other vertices that can be reached from it,
\[C_R(i) = \frac{1}{n-1}\sum_{j\ne i}[d_{ij} < \infty],\]and with edge weights \(w_e\), which represent connection strengths,
\[C_R(i) = \frac{1}{n-1}\sum_{j\ne i, d_{ij} < \infty} \frac{1}{d_{ij}}\sum_{e\in P_{ij}} w_e,\]i.e. the sum of the mean weights of the paths \(P_{ij}\) from \(i\) to the reachable vertices \(j\), where \(d_{ij}\) is the number of edges in the shortest path, and among several shortest paths the one with the largest total weight is taken [mones-hierarchy-2012]. For undirected graphs, the same weighted definition is used, and the unweighted one becomes
\[C_R(i) = \frac{1}{n-1}\sum_{j\ne i}\frac{1}{d_{ij}},\]i.e. the harmonic closeness (see
closeness()).The algorithm runs a breadth-first search from each vertex, in time \(O(V(V+E))\).
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
[mones-hierarchy-2012] (1,2)Enys Mones, Lilla Vicsek, and Tamás Vicsek, “Hierarchy measure for complex networks”, PLoS ONE 7, e33799 (2012), DOI: 10.1371/journal.pone.0033799 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["celegansneural"] >>> lrc = gt.local_reaching_centrality(g) >>> print(lrc.a.argmax(), lrc.a.max()) 247 0.902027027...
The values can be visualized for a smaller network, such as a random tree generated with
price_network(), with the edges directed away from its root:>>> g = gt.price_network(50) >>> g.set_reversed(True) >>> lrc = gt.local_reaching_centrality(g) >>> cmap = matplotlib.colors.LinearSegmentedColormap.from_list( ... "gray-blue", ["#d9d9d9", "#7dabd1"]) >>> gt.graph_draw(g, gt.sfdp_layout(g), vertex_fill_color=lrc, vcmap=cmap, ... vertex_size=gt.prop_to_size(lrc, mi=5, ma=20), ... output="local_reaching_centrality-price.pdf") <...>
Local reaching centrality of the vertices of a random tree generated with the Price model, with the edges directed away from the root. The vertex colors, from gray to blue, and the vertex sizes increase with the value.#