ClosenessCentrality for a graph g is given as where is the average distance from vertex to all other vertices connected to .
If is the distance matrix then the average distance from vertex to all connected vertices is given by , where the sum is taken over all finite and is the number of vertices connected to .
The closeness centrality for isolated vertices is taken to be zero.