subgraph_centrality(G)
Subgraph centrality of a node n
is the sum of weighted closed walks of all lengths starting and ending at node n
. The weights decrease with path length. Each closed walk is associated with a connected subgraph ().
This version of the algorithm computes eigenvalues and eigenvectors of the adjacency matrix.
Subgraph centrality of a node :None:None:`u`
in G can be found using a spectral decomposition of the adjacency matrix ,
where :None:None:`v_j`
is an eigenvector of the adjacency matrix :None:None:`A`
of G corresponding to the eigenvalue :None:None:`\lambda_j`
.
If the graph is not undirected and simple.
Dictionary of nodes with subgraph centrality as the value.
Returns subgraph centrality for each node in G.
subgraph_centrality_exp
Alternative algorithm of the subgraph centrality for each node of G.
(Example from ) >>> 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(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']
See :The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.centrality.subgraph_alg.subgraph_centrality_exp
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them