TL;DR
The clustering coefficient of a vertex asks a simple question: of all the pairs of neighbours that a vertex has, how many of those pairs are joined to each other? The answer is a fraction between 0 and 1. A vertex whose friends all know one another scores 1, and a vertex whose friends never know one another scores 0. It matters because many real networks have much more of this closed, triangle-rich structure than random networks of the same size.
Builds on: Graph, Vertex Degree · Leads to: the small-world model, Degree Distribution
Where it's used
Friend groups. Take one person in a social network. Their friends often know each other: a family, a team, or a class forms a tight cluster. The clustering coefficient measures how strongly a person's network of friends is closed in this way, and it is a standard number in studies of friendship networks.
Protein interaction maps. In biology, a network (a Graph) has proteins as its vertices, and a line joins two proteins that bind each other. Proteins that work together in one machine tend to bind each other in small groups. High clustering around a protein is a hint that it sits inside such a group, and researchers use this hint to suggest which proteins might share a job.
Small-world networks. Duncan Watts and Steven Strogatz noticed in 1998 that many real networks, such as the social network of film actors and the power grid of the western United States, combine high clustering with short paths between any two vertices. A purely random graph of the same size has short paths but very little clustering. The clustering coefficient is the number that separates the two cases, and it is the reason the small-world model was built.
How it works
Take a small friendship network with five people: Ana, Ben, Cara, Dev and Eli. Ana is friends with Ben, Cara and Dev. Ben and Cara are friends, Cara and Dev are friends, and Eli is friends only with Dev. We want Ana's clustering coefficient.
-
Find the neighbours. Ana's neighbours are Ben, Cara and Dev. Her degree is 3. Check: three friends, so the degree is 3.
-
List every pair of neighbours. There are three pairs: Ben and Cara, Ben and Dev, Cara and Dev. Check: three people give 3 pairs, because you pick 2 of them and the order does not matter.
-
Count the pairs that are joined. Ben and Cara are friends, so that pair counts. Ben and Dev are not friends, so that pair does not count. Cara and Dev are friends, so that pair counts. The count is 2. Check: you looked at each of the three pairs exactly once.
-
Divide by the number of possible pairs. The count is 2 out of 3 possible pairs, so the clustering coefficient is . Check: is between 0 and 1, as every clustering coefficient must be.
-
Read the result. Ana's friends know each other about two times in three. That is high clustering for a friend group of this size.
flowchart LR A[Pick a vertex] --> B[List its neighbours] B --> C[Count joined pairs of neighbours] C --> D[Divide by all possible pairs] D --> E[Clustering coefficient in 0 to 1]
The math
Definition
Let be a simple Graph. For a vertex with degree , let be its set of neighbours. Let be the number of edges that have both ends in . The local clustering coefficient of is
Here is the number of ways to choose two of the neighbours (the standard counting rule for choosing a pair), which is the number of possible pairs.
Read the formula as follows: is the count of joined pairs among the neighbours, and the denominator is the count of all pairs. The fraction is the share of possible pairs that are joined. This is steps 3 and 4 of the walkthrough written in symbols.
Steps 2 to 4 in symbols
For Ana, , so the number of possible pairs is . This matches the three pairs we listed. The joined pairs are Ben–Cara and Cara–Dev, so .
Beyond one vertex (not a walkthrough step)
One vertex tells you about its neighbourhood. To describe the whole graph, take the average of the local values over all vertices. Vertices of degree 0 or 1 have no pairs of neighbours, so their value is not defined. The usual convention sets it to 0, and some texts leave those vertices out of the average. The average clustering coefficient is
where the sum is the sum of the local values, and is the number of vertices. This is the average of the list of local values.
Worked examples
Take three vertices in a line: joined to , and joined to .
- Vertex has neighbours and , so .
- The number of possible pairs is : the single pair , .
- Is joined to ? No. So .
- The clustering coefficient is .
- Interpretation: links two people who do not know each other, so its neighbourhood has no closure at all.
Take four vertices , , , with edges , , , and the diagonal . The sets of neighbours are , , and .
- Vertex has , so there are pairs: , , .
- Joined pairs among them: yes, yes, no. So and .
- Vertex has , so there is one pair, . It is joined, so and .
- Vertex has , so the pairs are , , . Joined: yes, yes, no. So .
- Vertex has , with the pair , which is joined. So .
- Average: , about .
- Interpretation: the two vertices with degree 2 are fully closed, and the two with degree 3 are closed most of the time.
Ana has four friends: Ben, Cara, Dev and Eli. Among these four, the friendships are Ben–Cara, Cara–Dev and Dev–Eli.
- Ana's degree is .
- The number of possible pairs among four friends is .
- Joined pairs: Ben–Cara yes, Cara–Dev yes, Dev–Eli yes. The other three pairs (Ben–Dev, Ben–Eli, Cara–Eli) are not joined. So .
- The clustering coefficient is .
- Interpretation: half of the possible friendships among Ana's friends exist. Her circle is partly closed, with two small chains of friends rather than one tight group.
Try it: a person has 5 contacts, and 4 of the 10 possible pairs of those contacts know each other. What is the person's clustering coefficient?
Answer: . The number of possible pairs is , and the fraction of joined pairs is .
Common mistakes and tradeoffs
Mistake 1: counting edges instead of pairs. It is tempting to divide the number of edges around a vertex by its degree. In fact the denominator is the number of pairs of neighbours, , not . Ana has 3 edges to friends and 3 pairs of friends, but the pairs are what the clustering coefficient counts. With and 3 joined pairs, dividing by 4 would give , which is wrong; the correct value is .
Mistake 2: confusing the local and the global measure. It is tempting to think that the average of the local values is the same as the overall fraction of closed structures. In fact they differ. The global version, usually called transitivity, is , where is the number of triangles and is the number of connected triples, meaning sets of two edges that share a middle vertex. For the square with a diagonal in Example 2, (the triangles and ) and , so transitivity is . The average local value is . Both are valid, but they answer different questions, and the global one weights high-degree vertices more heavily.
Mistake 3: treating degree 0 and 1 as zero, as if it were a fact. A vertex with one friend has no pairs of friends, so its clustering coefficient is not defined. Setting it to 0 is a convention that changes the average. Always say which convention you used.
When to use it: it is the standard way to ask whether a network has tight local groups. It is cheap to compute: one pass over each neighbourhood.
When not to use it: it says nothing about how far apart two distant vertices are. A network can have high clustering and still have long paths. For that, look at path lengths, and compare the clustering with a random model such as the Erdős–Rényi random graph of the same size and density. For the overall spread of degrees, see the Degree Distribution. To check whether two vertices are joined, the Adjacency Matrix is faster than scanning neighbour lists.
History
Sociologists studied the tendency for "a friend of a friend is also a friend" for a long time, often under the name transitivity, long before the measure had a standard form. Network physicists brought the local clustering coefficient into common use. In 1998 Watts and Strogatz showed that a small amount of random rewiring in a regular ring of vertices gave a network with high clustering and short paths at the same time, which is the combination found in many real networks. Their work made the clustering coefficient a standard reference number for comparing real networks with random ones. The Wikipedia article on the clustering coefficient gives the standard definitions and their variants.
Recap
- A vertex's clustering coefficient is the fraction of pairs of its neighbours that are joined to each other.
- Its formula is , where counts the joined pairs among the neighbours.
- The average over all vertices summarises a whole graph, and degree 0 or 1 needs a stated convention.
- Clustering is compared with path lengths and random models, which is the basis of the small-world model.
What to read next: the small-world model uses this measure to build networks that are both clustered and short-path. The Degree Distribution describes the other basic statistic of a network.
Check yourself
QuestionA vertex has 4 neighbours. How many pairs of neighbours are there?Show answer
Choose 2 of the 4 neighbours: pairs.
QuestionA vertex has degree 5, and 6 of the possible pairs of its neighbours are joined. What is its clustering coefficient?Show answer
The number of possible pairs is . The clustering coefficient is .
QuestionWhy is the clustering coefficient always between 0 and 1?Show answer
It is a count of joined pairs, , divided by the count of all possible pairs, . The joined pairs are a subset of the possible pairs, so the count on top can be no larger than the count on the bottom. The smallest it can be is 0, when no pair is joined, and the largest is 1, when every pair is joined.
QuestionTwo vertices both have degree 4. One has clustering 1 and the other has clustering 0. What does this say about their friends?Show answer
The vertex with clustering 1 has friends who all know each other, so its neighbourhood is one tight group. The vertex with clustering 0 has friends who never know each other, so each friend connects it to a different part of the network. Both have the same number of friends, but the structure around them is completely different.
QuestionA network has 5 vertices with clustering values 1, 0, 0.5, 0.5 and 0 (the last one is a degree-1 vertex, set to 0 by convention). What is the average clustering coefficient?Show answer
The sum is . Dividing by gives .