group_closeness_centrality(G, S, weight=None)[source]

Compute the group closeness centrality for a group of nodes.

Group closeness centrality of a group of nodes \(S\) is a measure of how close the group is to the other nodes in the graph.

\[ \begin{align}\begin{aligned}c_{close}(S) = \frac{|V-S|}{\sum_{v \in V-S} d_{S, v}}\\d_{S, v} = min_{u \in S} (d_{u, v})\end{aligned}\end{align} \]

where \(V\) is the set of nodes, \(d_{S, v}\) is the distance of the group \(S\) from \(v\) defined as above. (\(V-S\) is the set of nodes in \(V\) that are not in \(S\)).


A NetworkX graph.

Slist or set

S is a group of nodes which belong to G, for which group closeness centrality is to be calculated.

weightNone or string, optional (default=None)

If None, all edge weights are considered equal. Otherwise holds the name of the edge attribute used as weight. The weight of an edge is treated as the length or distance between the two sides.


Group closeness centrality of the group S.


If node(s) in S are not present in G.


The measure was introduced in [1]. The formula implemented here is described in [2].

Higher values of closeness indicate greater centrality.

It is assumed that 1 / 0 is 0 (required in the case of directed graphs, or when a shortest path length is 0).

The number of nodes in the group must be a maximum of n - 1 where n is the total number of nodes in the graph.

For directed graphs, the incoming distance is utilized here. To use the outward distance, act on G.reverse().

For weighted graphs the edge weights must be greater than zero. Zero edge weights can produce an infinite number of equal length paths between pairs of nodes.



M G Everett and S P Borgatti: The Centrality of Groups and Classes. Journal of Mathematical Sociology. 23(3): 181-201. 1999.


J. Zhao et. al.: Measuring and Maximizing Group Closeness Centrality over Disk Resident Graphs. WWWConference Proceedings, 2014. 689-694.