When is the Closeness Centrality Algorithm best applied?

By Fatima Rubio, Sr. Data Scientist

January 6, 2023

Blog

Reading Time: 5 minutes

The Closeness Centrality algorithm is uniquely valuable in graph data science (GDS) and is commonly used to detect nodes that can spread information efficiently, measuring how central a node is to the group. In our Betweenness Centrality article, we briefly introduced centrality algorithms overall as some of the most commonly utilized algorithm types in GDS.

What is Closeness Centrality?

Closeness Centrality algorithms in general are unique because they are typically used to find nodes that can quickly interact with other nodes. A closeness centrality example where we care about how central a node is to the group is a disease spreading across the network which is represented in this context by nodes with high closeness centrality scores, which could represent potential superspreaders.

Here we will look at what is this algorithm and examine how it works conceptually and how can we account for edge cases, and then look at a use case to have a better grasp of the algorithm’s uses.

Mathematical Concepts

Closeness centrality indicates the degree of centrality, or how close a node is to all other nodes in the context of the network centrality. It is calculated as the average of the shortest path length from the node to every other node in the network.

While degree centrality measures how many neighbors a node has, the centrality score for this algorithm gives us an idea of the accessibility of one node with respect to all others. The node closest to all others, following the shortest path possible, has a higher accessibility and communication capacity to the other nodes. The logical next step is to look at how to calculate closeness centrality.

Undirected Network

In an undirected network, we estimate the shortest path to each node. In the graph network example shown in Figure 1, we can estimate the shortest path to each one of the 8 different nodes. For instance, the degree centrality of node A would be 1, while the shortest (geodesic) path from node A to node D would be 3 (D–C–B–A).

Closeness Centrality Example in an Undirected Graph Network
Figure 1: Undirected Graph Network Example.

Building the geodesic distance matrix for all nodes in the graph network of Figure 1, Table 1 shows the shortest path from each one of the nodes to all others. It’s worth noting that the values on the left side of the diagonal match the ones on the right side, as the graph network is undirected.

ABCDEFGHNormalized Score
A012345540.35
B101234430.39
C210123320.50
D321012210.58
E432101110.54
F543210120.39
G543211010.41
H432112100.50
Table 1: Geodesic Distance Matrix, resulting from the nodes in the graph network of Figure 1.

The closeness centrality score for each one of the nodes in the network is estimated as the sum of the path of all other nodes divided by the number of nodes minus one. For example, for node D, the closeness centrality score would be 1÷(3+2+1+1+2+2+1) = 0.083; for node A, it would be 1÷(1+2+3+4+5+5+4) = 0.042. Comparing the score of both nodes, node D is more central than node A.

To account for the size of the network, we normalize the score by multiplying by the number of nodes minus one, assuming all nodes are connected to the network. The mathematical conceptual equation for the Closeness Centrality formula would be as shown in Equation 1. For example, for node D, the closeness centrality score would be 7÷(3+2+1+1+2+2+1) = 0.58.

Normalized Centrality Score
Equation 1: Normalized Centrality Score

Wasserman & Faust (1994) have proposed an improved formula for dealing with n” unconnected nodes in a graph network. Alternatively, Beauchamp (1965) proposed to zero out all distances that were not accessible and therefore turned into infinity distances. This score is known as harmonic centrality (Neo4j offers a good article on this here).

Directed Network

In the case of directed networks, most software only calculates the outbound closeness centrality, considering the outbound relationships: the most important node is the one that can reach all other nodes in the network most quickly and helps define good broadcasters (e.g., Instagram), which is important in diffusion processes.

The inbound closeness centrality accounts for the inbound relationships and it can be useful if we want to find the optimal location for a customer or improve the search results of a website; in these cases, the incoming parts are meaningful.

Website searches represent another good closeness centrality example to better grasp the difference between the outbound and inbound closeness centrality score: we can have a high closeness centrality from outgoing website links, but low closeness centrality from incoming website links.

Weighted Network

We can also calculate closeness centrality in weighted networks, where the distances are not always going to be the same. In this case, the shortest path is not the one with the least hops but the one with the minimum total weighted distance. For instance, in the example shown in Figure 2, accounting for weighted paths, the shortest distance between nodes D and G includes two hopes (D-F-G=2), instead of the single hop option (D-G=5).

Closeness Centrality Example in a Weighted Graph Network
Figure 2: Weighted Graph Network Example.

As the geodesic matrix in Table 2 shows, in this example, the normalized closeness centrality score for node B is 9÷(1+2+3+1+2+1+1+4+7) = 0.41, which turns out to be the most central node in this network, and for node J, it is 9÷(8+7+9+10+10+9+8+6+3) = 0.13, resulting to be the farthest node.

ABCDEFGHIJNormalized Score
A01142322580.32
B10231211470.41
C12031433690.28
D433021247100.25
E211203247100.28
F32413013690.28
G21322102580.35
H21344320360.32
I54677653030.19
J8791010986300.13
Table 2: Geodesic Distance Matrix, resulting from the nodes in the graph network of Figure 2.
When do we use a Closeness Centrality Algorithm?

The closeness centrality algorithm can be used in a number of various use cases, it is often used in social networks to know how fast the data propagates through short routes (e.g. Kiss & Bichler, 2008) or to estimate the arrival of the information transmitted within a telecommunication channel.

The algorithm’s score can also be applied to estimate an optimal postal route based on the shortest paths for parcel delivery services.

When selecting closeness centrality amongst the different centrality algorithms, we should keep in mind that:

  • The position of the node is related to the entire network (big advantage!).
  • Closeness Centrality is sensitive to changes in the network.
  • All nodes must be reachable as a constraint to estimate the closeness centrality score.
Conclusions

So what is closeness centrality? As mentioned in the introduction, a Closeness Centrality algorithm is used to detect which nodes are more efficient at spreading information through the network by measuring how central a node is to the network as whole.

Depending on the nature of the network (undirected vs. directed vs. weighted), we should estimate the normalized closeness score to determine which node is the most central to the network. From this we are able to find the optimal node which allows data to propagate through the shortest paths in the network.

Read related articles on graph algorithms including the betweenness centrality article as well as this one on graph traversal algorithms.


Graphable delivers insightful graph database (e.g. Neo4j consulting) / machine learning (ml) / natural language processing (nlp) projects as well as graph and Domo consulting for BI/analytics, with measurable impact. We are known for operating ethically, communicating well, and delivering on-time. With hundreds of successful projects across most industries, we thrive in the most challenging data integration and data science contexts, driving analytics success.

Still learning? Check out a few of our introductory articles to learn more:

Want to find out more about our Hume consulting on the Hume (GraphAware) Platform? As the Americas principal reseller, we are happy to connect and tell you more. Book a demo today.

We would also be happy to learn more about your current project and share how we might be able to help. Schedule a consultation with us today. We can discuss Neo4j pricing or Domo pricing, or any other topic. We look forward to speaking with you!


We are known for operating ethically, communicating well, and delivering on-time. With hundreds of successful projects across most industries, we thrive in the most challenging data integration and data science contexts, driving analytics success.
Contact us for more information: