closeness_vitality#

closeness_vitality(G, node=None, weight=None, wiener_index=None)[source]#

Returns the closeness vitality for nodes in the graph.

The closeness vitality of a node, defined in Section 3.6.2 of [1], is the change in the sum of distances between all node pairs when excluding that node.

Parameters:
GNetworkX graph

A strongly-connected graph.

weightstring

The name of the edge attribute used as weight. This is passed directly to the wiener_index() function.

nodeobject

If specified, only the closeness vitality for this node will be returned. Otherwise, a dictionary mapping each node to its closeness vitality will be returned.

Returns:
dictionary or float

If node is None, this function returns a dictionary with nodes as keys and closeness vitality as the value. Otherwise, it returns only the closeness vitality for the specified node.

The closeness vitality of a node may be negative infinity if removing that node would disconnect the graph.

Other Parameters:
wiener_indexnumber

If you have already computed the Wiener index of the graph G, you can provide that value here. Otherwise, it will be computed for you.

See also

closeness_centrality

References

[1]

Ulrik Brandes, Thomas Erlebach (eds.). Network Analysis: Methodological Foundations. Springer, 2005. <http://books.google.com/books?id=TTNhSm7HYrIC>

Examples

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

Additional backends implement this function

parallelA networkx backend that uses joblib to run graph algorithms in parallel. Find the nx-parallel’s configuration guide here

The parallel computation is implemented only when the node is not specified. The closeness vitality for each node is computed concurrently.

Additional parameters:
get_chunksstr, function (default = “chunks”)

A function that takes in a list of all the nodes as input and returns an iterable node_chunks. The default chunking is done by slicing the nodes into n_jobs number of chunks.

[Source]