V
- the graph vertex typeE
- the graph edge typepublic final class HarmonicCentrality<V,E> extends ClosenessCentrality<V,E>
The harmonic centrality of a vertex $x$ is defined as $H(x)=\sum_{y \neq x} 1/d(x,y)$, where $d(x,y)$ is the shortest path distance from $x$ to $y$. In case a distance $d(x,y)=\infinity$, then $1/d(x,y)=0$. When normalization is used the score is divided by $n-1$ where $n$ is the total number of vertices in the graph. For details see the following papers:
This implementation computes by default the centrality using outgoing paths and normalizes the scores. This behavior can be adjusted by the constructor arguments.
Shortest paths are computed either by using Dijkstra's algorithm or Floyd-Warshall depending on whether the graph has edges with negative edge weights. Thus, the running time is either $O(n (m + n \log n))$ or $O(n^3)$ respectively, where $n$ is the number of vertices and $m$ the number of edges of the graph.
graph, incoming, normalize, scores
Constructor and Description |
---|
HarmonicCentrality(Graph<V,E> graph)
Construct a new instance.
|
HarmonicCentrality(Graph<V,E> graph,
boolean incoming,
boolean normalize)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
compute()
Compute the centrality index
|
getScores, getShortestPathAlgorithm, getVertexScore
public HarmonicCentrality(Graph<V,E> graph)
graph
- the input graphpublic HarmonicCentrality(Graph<V,E> graph, boolean incoming, boolean normalize)
graph
- the input graphincoming
- if true incoming paths are used, otherwise outgoing pathsnormalize
- whether to normalize by dividing the closeness by $n-1$, where $n$ is the
number of vertices of the graphprotected void compute()
ClosenessCentrality
compute
in class ClosenessCentrality<V,E>
Copyright © 2019. All rights reserved.