closeness_vitality

closeness_vitality#

graph_tool.centrality.closeness_vitality(g, weight=None, source=None, vprop=None)[git][source]#

Calculate the closeness vitality of each vertex.

Parameters:
gGraph

Graph to be used.

weightEdgePropertyMap (optional, default: None)

Edge lengths. If not supplied, every edge has unit length.

sourceVertex (optional, default: None)

If specified, the vitality is computed for this vertex alone.

vpropVertexPropertyMap (optional, default: None)

Vertex property map to store the vitality values.

Returns:
vitalityVertexPropertyMap or float

A vertex property map with the closeness vitality values, or a single value if source is given.

See also

closeness

Closeness centrality

laplacian_centrality

Laplacian centrality

graph_tool.structure.wiener_index

Sum of the shortest-path distances

Notes

The closeness vitality [koschutzki-centrality-2005] of a vertex \(v\) is the increase of the sum of the distances between all pairs of vertices (the Wiener index)

\[W(G) = \sum_{s\ne t} d_{st}\]

when \(v\) is removed, \(W(G) - W(G\setminus v)\), where the sum is over the ordered pairs for directed graphs and the unordered ones for undirected graphs. If the graph is not (strongly) connected, \(W(G)=\infty\), and so is the vitality of the vertices whose removal leaves it connected, while for the others it is undefined (nan); the vitality of the vertices whose removal disconnects a connected graph is \(-\infty\).

The Wiener index of \(G\setminus v\) is computed with searches from all vertices for each \(v\), in time \(O(V^2(V+E))\) for unweighted graphs and \(O(V^2(V+E)\log V)\) for weighted graphs (or a factor \(V\) less if source is given).

Parallel implementation.

If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.

References

[koschutzki-centrality-2005]

Dirk Koschützki, Katharina Anna Lehmann, Leon Peeters, Stefan Richter, Dagmar Tenfelde-Podehl, and Oliver Zlotowski, “Centrality indices”, in Network Analysis, edited by U. Brandes and T. Erlebach, Lecture Notes in Computer Science 3418, 16-61 (2005), DOI: 10.1007/978-3-540-31955-9_3 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> cv = gt.closeness_vitality(g)
>>> print(cv.a.argmax(), cv.a.max())
16 116.0