incremental_closeness_centrality(G, edge, prev_cc=None, insertion=True, wf_improved=True)
Compute closeness centrality for nodes using level-based work filtering as described in Incremental Algorithms for Closeness Centrality by Sariyuce et al.
Level-based work filtering detects unnecessary updates to the closeness centrality and filters them out.
--- From "Incremental Algorithms for Closeness Centrality":
Theorem 1: Let $G = (V, E)$ be a graph and u and v be two vertices in V such that there is no edge (u, v) in E. Let $G' = (V, E \cup uv)$ Then $cc[s] = cc'[s]$ if and only if $\left|dG(s, u) - dG(s, v)\right| \leq 1$ .
Where $dG(u, v)$ denotes the length of the shortest path between two vertices u, v in a graph G, cc[s] is the closeness centrality for a vertex s in V, and cc'[s] is the closeness centrality for a vertex s in V, with the (u, v) edge added. ---
We use Theorem 1 to filter out updates when adding or removing an edge. When adding an edge (u, v), we compute the shortest path lengths from all other nodes to u and to v before the node is added. When removing an edge, we compute the shortest path lengths after the edge is removed. Then we apply Theorem 1 to use previously computed closeness centrality for nodes where $\left|dG(s, u) - dG(s, v)\right| \leq 1$ . This works only for undirected, unweighted graphs; the distance argument is not supported.
Closeness centrality of a node :None:None:`u`
is the reciprocal of the sum of the shortest path distances from :None:None:`u`
to all :None:None:`n-1`
other nodes. Since the sum of distances depends on the number of nodes in the graph, closeness is normalized by the sum of minimum possible distances :None:None:`n-1`
.
where :None:None:`d(v, u)`
is the shortest-path distance between v
and :None:None:`u`
, and n
is the number of nodes in the graph.
Notice that higher values of closeness indicate higher centrality.
The closeness centrality is normalized to :None:None:`(n-1)/(|G|-1)`
where n
is the number of nodes in the connected part of graph containing the node. If the graph is not completely connected, this algorithm computes the closeness centrality for each connected part separately.
A NetworkX graph
The modified edge (u, v) in the graph.
The previous closeness centrality for all nodes in the graph.
If True (default) the edge was inserted, otherwise it was deleted from the graph.
If True, scale by the fraction of nodes reachable. This gives the Wasserman and Faust improved formula. For single component graphs it is the same as the original formula.
Dictionary of nodes with closeness centrality as the value.
Incremental closeness centrality for nodes.
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.centrality.closeness.closeness_centrality
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