subgraph_centrality_exp#
- subgraph_centrality_exp(G)[source]#
Returns the subgraph centrality for each node of G.
Subgraph centrality of a node
n
is the sum of weighted closed walks of all lengths starting and ending at noden
. The weights decrease with path length. Each closed walk is associated with a connected subgraph ([1]).- Parameters:
- G: graph
- Returns:
- nodes:dictionary
Dictionary of nodes with subgraph centrality as the value.
- Raises:
- NetworkXError
If the graph is not undirected and simple.
See also
subgraph_centrality
Alternative algorithm of the subgraph centrality for each node of G.
Notes
This version of the algorithm exponentiates the adjacency matrix.
The subgraph centrality of a node
u
in G can be found using the matrix exponential of the adjacency matrix of G [1],\[SC(u)=(e^A)_{uu} .\]References
[1] (1,2,3)Ernesto Estrada, Juan A. Rodriguez-Velazquez, βSubgraph centrality in complex networksβ, Physical Review E 71, 056103 (2005). https://arxiv.org/abs/cond-mat/0504730
Examples
(Example from [1]) >>> G = nx.Graph( β¦ [ β¦ (1, 2), β¦ (1, 5), β¦ (1, 8), β¦ (2, 3), β¦ (2, 8), β¦ (3, 4), β¦ (3, 6), β¦ (4, 5), β¦ (4, 7), β¦ (5, 6), β¦ (6, 7), β¦ (7, 8), β¦ ] β¦ ) >>> sc = nx.subgraph_centrality_exp(G) >>> print([fβ{node} {sc[node]:0.2f}β for node in sorted(sc)]) [β1 3.90β, β2 3.90β, β3 3.64β, β4 3.71β, β5 3.64β, β6 3.71β, β7 3.64β, β8 3.90β]