NetworkX

Previous topic

networkx.closeness_vitality

Next topic

Functions

networkx.closeness_vitality

closeness_vitality(G, v=None, weighted_edges=False)

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.

weighted_edges : bool, optional

Consider the edge weights in determining the shortest paths. If False, all edge weights are considered equal.

Returns:

nodes : dictionary

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

Examples

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