NetworkX

Previous topic

networkx.algorithms.centrality.out_degree_centrality

Next topic

networkx.algorithms.centrality.betweenness_centrality

networkx.algorithms.centrality.closeness_centrality

networkx.algorithms.centrality.closeness_centrality(G, v=None, weighted_edges=False, normalized=True)

Compute closeness centrality for nodes.

Closeness centrality at a node is 1/average distance to all other nodes.

Parameters :

G : graph

A networkx graph

v : node, optional

Return only the value for node v

weighted_edges : bool, optional

If True use edge weights in computing degree and size.

normalized : bool, optional

If True (default) normalize by the graph size.

Returns :

nodes : dictionary

Dictionary of nodes with closeness centrality as the value.

Notes

The closeness centrality is normalized to to n-1 / size(G)-1 where n is the number of nodes in the connected part of graph containing the node. If the graph is not completely connected, this algorithm computes the closeness centrality for each connected part separately.