Harmonic Centrality
Glossary
 Directed

Directed trait. The algorithm is welldefined on a directed graph.
 Directed

Directed trait. The algorithm ignores the direction of the graph.
 Directed

Directed trait. The algorithm does not run on a directed graph.
 Undirected

Undirected trait. The algorithm is welldefined on an undirected graph.
 Undirected

Undirected trait. The algorithm ignores the undirectedness of the graph.
 Heterogeneous nodes

Heterogeneous nodes fully supported. The algorithm has the ability to distinguish between nodes of different types.
 Heterogeneous nodes

Heterogeneous nodes allowed. The algorithm treats all selected nodes similarly regardless of their label.
 Heterogeneous relationships

Heterogeneous relationships fully supported. The algorithm has the ability to distinguish between relationships of different types.
 Heterogeneous relationships

Heterogeneous relationships allowed. The algorithm treats all selected relationships similarly regardless of their type.
 Weighted relationships

Weighted trait. The algorithm supports a relationship property to be used as weight, specified via the relationshipWeightProperty configuration parameter.
 Weighted relationships

Weighted trait. The algorithm treats each relationship as equally important, discarding the value of any relationship weight.
Harmonic centrality (also known as valued centrality) is a variant of closeness centrality, that was invented to solve the problem the original formula had when dealing with unconnected graphs. As with many of the centrality algorithms, it originates from the field of social network analysis.
This feature is in the alpha tier. For more information on feature tiers, see API Tiers.
1. History and explanation
Harmonic centrality was proposed by Marchiori and Latora in Harmony in the Small World while trying to come up with a sensible notion of "average shortest path".
They suggested a different way of calculating the average distance to that used in the Closeness Centrality algorithm. Rather than summing the distances of a node to all other nodes, the harmonic centrality algorithm sums the inverse of those distances. This enables it deal with infinite values.
The raw harmonic centrality for a node is calculated using the following formula:
raw harmonic centrality(node) = sum(1 / distance from node to every other node excluding itself)
As with closeness centrality, we can also calculate a normalized harmonic centrality with the following formula:
normalized harmonic centrality(node) = sum(1 / distance from node to every other node excluding itself) / (number of nodes  1)
In this formula, ∞ values are handled cleanly.
2. Usecases  when to use the Harmonic Centrality algorithm
Harmonic centrality was proposed as an alternative to closeness centrality, and therefore has similar use cases.
For example, we might use it if we’re trying to identify where in the city to place a new public service so that it’s easily accessible for residents. If we’re trying to spread a message on social media we could use the algorithm to find the key influencers that can help us achieve our goal.
3. Syntax
CALL gds.alpha.closeness.harmonic.write(configuration: Map)
YIELD nodes, preProcessingMillis, computeMillis, writeMillis, centralityDistribution
Name  Type  Default  Optional  Description 

concurrency 
int 
4 
yes 
The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency' and 'writeConcurrency'. 
readConcurrency 
int 
value of 'concurrency' 
yes 
The number of concurrent threads used for reading the graph. 
writeConcurrency 
int 
value of 'concurrency' 
yes 
The number of concurrent threads used for writing the result. 
writeProperty 
string 
'centrality' 
yes 
The property name written back to. 
Name  Type  Description 

nodes 
int 
The number of nodes considered. 
preProcessingMillis 
int 
Milliseconds for preprocessing the data. 
computeMillis 
int 
Milliseconds for running the algorithm. 
writeMillis 
int 
Milliseconds for writing result data back. 
writeProperty 
string 
The property name written back to. 
centralityDistribution 
Map 
Map containing min, max, mean as well as p50, p75, p90, p95, p99 and p999 percentile values of centrality values. 
CALL gds.alpha.closeness.harmonic.stream(configuration: Map)
YIELD nodeId, centrality
Name  Type  Default  Optional  Description 

concurrency 
int 
4 
yes 
The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency' and 'writeConcurrency'. 
readConcurrency 
int 
value of 'concurrency' 
yes 
The number of concurrent threads used for reading the graph. 
Name  Type  Description 

node 
long 
Node ID 
centrality 
float 
Harmonic centrality score 
4. Harmonic Centrality algorithm sample
CREATE (a:Node{id:"A"}),
(b:Node{id:"B"}),
(c:Node{id:"C"}),
(d:Node{id:"D"}),
(e:Node{id:"E"}),
(a)[:LINK]>(b),
(b)[:LINK]>(c),
(d)[:LINK]>(e)
CALL gds.graph.project(
'graph',
'Node',
'LINK'
)
CALL gds.alpha.closeness.harmonic.stream('graph', {})
YIELD nodeId, centrality
RETURN gds.util.asNode(nodeId).name AS user, centrality
ORDER BY centrality DESC
Name  Centrality weight 

B 
0.5 
A 
0.375 
c 
0.375 
D 
0.25 
E 
0.25 
CALL gds.alpha.closeness.harmonic.write('graph', {})
YIELD nodes, writeProperty
nodes  writeProperty 

5 
"centrality" 
Was this page helpful?