networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
second_order_centrality(G)

The second order centrality of a given node is the standard deviation of the return times to that node of a perpetual random walk on G:

Notes

Lower values of second order centrality indicate higher centrality.

The algorithm is from Kermarrec, Le Merrer, Sericola and Trédan .

This code implements the analytical version of the algorithm, i.e., there is no simulation of a random walk process involved. The random walk is here unbiased (corresponding to eq 6 of the paper ), thus the centrality values are the standard deviations for random walk return times on the transformed input graph G (equal in-degree at each nodes by adding self-loops).

Complexity of this implementation, made to run locally on a single machine, is O(n^3), with n the size of G, which makes it viable only for small graphs.

Parameters

G : graph

A NetworkX connected and undirected graph.

Raises

NetworkXException

If the graph G is empty, non connected or has negative weights.

Returns

nodes : dictionary

Dictionary keyed by node with second order centrality as the value.

Compute the second order centrality for nodes of G.

See Also

betweenness_centrality

Examples

>>> G = nx.star_graph(10)
... soc = nx.second_order_centrality(G)
... print(sorted(soc.items(), key=lambda x: x[1])[0][0]) # pick first id 0
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.centrality.second_order.second_order_centrality

Local connectivity graph

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


GitHub : /networkx/algorithms/centrality/second_order.py#42
type: <class 'function'>
Commit: