In a social network such as the Facebook SPAN data, we will have influential people. In graph terminology, these are the influential nodes. Centrality finds features of important nodes. Closeness centrality uses shortest paths between nodes as a feature, as shown in the following equation:
In (8.3), d(u, v) is the shortest path between u, v, and n is the number of nodes. An influential node is close to other nodes and, therefore, the sum of the shortest paths is low. We can compute closeness centrality for each node separately, and for a large graph, this can be a lengthy calculation. NetworkX allows us to specify which node we are interested in, so we will calculate closeness centrality just for a few nodes.