gives a list of closeness centralities for the vertices in the graph g.


uses rules vw to specify the graph g.


  • ClosenessCentrality will give high centralities to vertices that are at a short average distance to every other reachable vertex.
  • ClosenessCentrality for a graph is given by , 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.
  • ClosenessCentrality works with undirected graphs, directed graphs, weighted graphs, multigraphs, and mixed graphs.


open allclose all

Basic Examples  (2)

Compute closeness centralities:


Rank vertices. Highest-ranked vertices are at a short average distance to every other vertex:

Scope  (7)

ClosenessCentrality works with undirected graphs:

Directed graphs:

Weighted graphs:


Mixed graphs:

Use rules to specify the graph:

ClosenessCentrality works with large graphs:

Applications  (9)

Rank vertices by their relative closeness to other vertices:

Highlight the closeness centrality for CycleGraph:




A computer ad hoc network can be modeled with a SpatialGraphDistribution. Find computers that can facilitate the quick spread of viruses in an infected network:

Critical computers:

Find the top 10 proteins that are most likely to be essential proteins in a protein interaction network of yeast:

In a regulatory network, genes are connected if there is a transcriptional regulatory intersection between them. Find the genes that are most likely to be global regulators:

A directed network that describes the flow of information among 10 organizations concerned with social welfare issues in one midwestern US city. Find the organization that can most efficiently communicate with every other organization:

A road network linking Chicago suburbs. Find the best location for hospitals and fire departments to minimize the distance traveled by emergency vehicles:

A power grid network representing the topology of the Western States Power Grid of the United States. Show that the closeness centrality follows a normal distribution:

Obtain the maximum likelihood parameter estimates, assuming a normal distribution:

Visually compare the PDFs for the original and estimated distributions:

For graphs with vertices, the largest sum in differences in closeness centrality between the most central vertex and all other vertices is the inverse of :

Measure how central the most central vertex is with respect to other vertices:

Centralization of social networks:

Properties & Relations  (4)

ClosenessCentrality is the inverse of the average distances to other reachable vertices:

The inverse of maximum distances to other reachable vertices:

Closeness centrality is between 0 and 1:

Closeness centralities for an undirected graph are equivalent to centralities for each component:

Computing the centralities for each component yields the same result:

Use VertexIndex to obtain the centrality of a specific vertex:

Wolfram Research (2010), ClosenessCentrality, Wolfram Language function, (updated 2015).


Wolfram Research (2010), ClosenessCentrality, Wolfram Language function, (updated 2015).


Wolfram Language. 2010. "ClosenessCentrality." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015.


Wolfram Language. (2010). ClosenessCentrality. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_closenesscentrality, author="Wolfram Research", title="{ClosenessCentrality}", year="2015", howpublished="\url{}", note=[Accessed: 18-July-2024 ]}


@online{reference.wolfram_2024_closenesscentrality, organization={Wolfram Research}, title={ClosenessCentrality}, year={2015}, url={}, note=[Accessed: 18-July-2024 ]}