networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturns
group_closeness_centrality(G, S, weight=None)

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.

$$c_{close}(S) = \frac{|V-S|}{\sum_{v \in V-S} d_{S, v}} d_{S, v} = min_{u \in S} (d_{u, v})$$

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$).

Notes

The measure was introduced in . The formula implemented here is described in .

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 :None:None:`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.

Parameters

G : graph

A NetworkX graph.

S : list or set

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

weight : None 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.

Raises

NodeNotFound

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

Returns

closeness : float

Group closeness centrality of the group S.

Compute the group closeness centrality for a group of nodes.

See Also

closeness_centrality

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/centrality/group.py#546
type: <class 'function'>
Commit: