NetworkX

Previous topic

networkx.algorithms.vitality.closeness_vitality

Next topic

Functions

networkx.algorithms.vitality.closeness_vitality

networkx.algorithms.vitality.closeness_vitality(G, v=None, weight=None)

Compute closeness vitality for nodes.

Closeness vitality at a node is the change in the sum of distances between all node pairs when excluding a that node.

Parameters :

G : graph

A networkx graph

v : node, optional

Return only the value for node v.

weight : None, True or string, optional

If None, edge weights are ignored. If True, edge attribute ‘weight’ is used as weight of each edge. Otherwise holds the name of the edge attribute used as weight.

Returns :

nodes : dictionary

Dictionary with nodes as keys and closeness vitality as the value.

See also

closeness_centrality

Examples

>>> G=nx.cycle_graph(3)
>>> nx.closeness_vitality(G)
{0: 4.0, 1: 4.0, 2: 4.0}