networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturns
harmonic_centrality(G, nbunch=None, distance=None, sources=None)

Harmonic centrality of a node u is the sum of the reciprocal of the shortest path distances from all other nodes to u

$$C(u) = \sum_{v \neq u} \frac{1}{d(v, u)}$$

where :None:None:`d(v, u)` is the shortest-path distance between :None:None:`v` and u.

If :None:None:`sources` is given as an argument, the returned harmonic centrality values are calculated as the sum of the reciprocals of the shortest path distances from the nodes specified in :None:None:`sources` to u instead of from all nodes to u.

Notice that higher values indicate higher centrality.

Notes

If the 'distance' keyword is set to an edge attribute key then the shortest-path length will be computed using Dijkstra's algorithm with that edge attribute as the edge weight.

Parameters

G : graph

A NetworkX graph

nbunch : container (default: all nodes in G)

Container of nodes for which harmonic centrality values are calculated.

sources : container (default: all nodes in G)

Container of nodes :None:None:`v` over which reciprocal distances are computed. Nodes not in G are silently ignored.

distance : edge attribute key, optional (default=None)

Use the specified edge attribute as the edge distance in shortest path calculations. If :None:None:`None`, then each edge will have distance equal to 1.

Returns

nodes : dictionary

Dictionary of nodes with harmonic centrality as the value.

Compute harmonic centrality for nodes.

See Also

betweenness_centrality
closeness_centrality
degree_centrality
eigenvector_centrality
load_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/harmonic.py#9
type: <class 'function'>
Commit: