subgraph_centrality

subgraph_centrality#

graph_tool.centrality.subgraph_centrality(g, vprop=None)[git][source]#

Return the subgraph centrality of the vertices.

Parameters:
gGraph

Graph to be used.

vpropVertexPropertyMap (optional, default: None)

If provided, the values will be stored in this property map.

Returns:
scVertexPropertyMap

The subgraph centrality of every vertex.

See also

estrada_index

Sum of the subgraph centralities

communicability

Communicability between vertices

katz

Katz centrality

graph_tool.clustering.spectral_bipartivity

Spectral bipartivity

Notes

The subgraph centrality [estrada-subgraph-2005] is the weighted number of closed walks starting and ending at a vertex, with walks of length \(l\) weighted by \(1/l!\),

\[SC_i = \sum_{l=0}^{\infty}\frac{[\boldsymbol A^l]_{ii}}{l!} = [e^{\boldsymbol A}]_{ii},\]

where \(\boldsymbol A\) is the adjacency matrix (see adjacency()), whose entries count parallel edges, and self-loops twice for undirected graphs. It is computed from the eigendecomposition of the adjacency matrix (or from the matrix exponential, for directed graphs), in time \(O(V^3)\).

References

[estrada-subgraph-2005]

Ernesto Estrada and Juan A. Rodríguez-Velázquez, “Subgraph centrality in complex networks”, Physical Review E 71, 056103 (2005), DOI: 10.1103/PhysRevE.71.056103 [sci-hub, @tor], arXiv: cond-mat/0504730

Examples

>>> g = gt.collection.data["karate"]
>>> sc = gt.subgraph_centrality(g)
>>> print(sc.fa.argmax(), sc.fa.max())
33 136.7223381...

The values can be visualized by drawing the network with vertex colors and sizes given by them:

>>> cmap = matplotlib.colors.LinearSegmentedColormap.from_list(
...     "gray-blue", ["#d9d9d9", "#7dabd1"])
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=sc, vcmap=cmap,
...               vertex_size=gt.prop_to_size(sc, mi=5, ma=15),
...               output="subgraph_centrality-karate.pdf")
<...>
../_images/subgraph_centrality-karate.png

Subgraph centrality of the vertices of Zachary’s karate club network. The vertex colors, from gray to blue, and the vertex sizes increase with the value.#