group_closeness

group_closeness#

graph_tool.centrality.group_closeness(g, group, weight=None)[git][source]#

Calculate the closeness centrality of a group of vertices.

Parameters:
gGraph

Graph to be used.

grouplist or numpy.ndarray

Vertices of the group.

weightEdgePropertyMap (optional, default: None)

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

Returns:
GCfloat

The group closeness centrality.

See also

closeness

Closeness of single vertices

group_betweenness

Group betweenness centrality

group_degree

Group degree centrality

Notes

The group closeness [everett-centrality-1999] of a group \(C\) is

\[C_C(C) = \frac{n - |C|}{\sum_{v\notin C} d(v, C)},\]

where \(d(v, C) = \min_{u\in C}d(v, u)\) is the distance from \(v\) to the group (for directed graphs, along the edges towards the group). The vertices that cannot reach the group are omitted from the sum. It is computed with a single search from all vertices of the group, in time \(O(V + E)\) for unweighted graphs and \(O((V + E)\log V)\) for weighted graphs.

References

[everett-centrality-1999]

M. G. Everett and S. P. Borgatti, “The centrality of groups and classes”, The Journal of Mathematical Sociology 23, 181-201 (1999), DOI: 10.1080/0022250X.1999.9990219 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> print(gt.group_closeness(g, [0, 33]))
0.914285714...