easygraph.functions.centrality.closeness module#
- easygraph.functions.centrality.closeness.closeness_centrality(G, weight=None, sources=None, n_workers=None)[source]#
Compute closeness centrality for nodes.
\[C_{WF}(u) = \frac{n-1}{N-1} \frac{n - 1}{\sum_{v=1}^{n-1} d(v, u)},\]Notice that the closeness distance function computes the outcoming distance to u for directed graphs. To use incoming distance, act on G.reverse().
- Parameters:
G (graph) – A easygraph graph
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.
sources (None or nodes list, optional (default=None)) – If None, all nodes are returned Otherwise,the set of source vertices to creturn.
- Returns:
nodes – Dictionary of nodes with closeness centrality as the value.
- Return type:
dictionary