# What exactly does LocalClusteringCoefficient compute for directed graphs?

For undirected graphs, the LocalClusteringCoefficient of vertex v is

GraphDensity[Subgraph[g, AdjacencyList[g, v]]]


What precisely does Mathematica compute for directed graphs? The documentation states that this function supports directed graphs.

To take an example, can someone explain the result 1/2 for vertex 1 here?

g = Graph[{1, 2, 3, 4}, {1 -> 2, 2 -> 3, 3 -> 1, 1 -> 4},
VertexLabels -> "Name"]


LocalClusteringCoefficient[g]
(* {1/2, 1, 1, 0} *)


What about 1/3 here?

g = Graph[{1, 2, 3, 4}, {1 -> 2, 2 -> 3, 3 -> 1, 1 -> 4, 4 -> 1},
VertexLabels -> "Name"]

LocalClusteringCoefficient[g]
(* {1/3, 1, 1, 0} *)


• I'm really not sure what it calculates, I just want to add that GraphDensity[Subgraph[g, AdjacencyList[g, v]]] works for directed graphs as well as mentioned in the reference for GraphDensity and seems to give the correct results for both cases. Commented Dec 7, 2015 at 12:05
• @Graumagier Well, "correct" depends on how we define the local clustering coefficient :) GraphDensity[Subgraph[g, AdjacencyList[g, v]]] "works" (as in it returns some well defined result) for directed graphs, but it's good to remember that AdjacencyList ignores edge directions while GraphDensity doesn't. This is reasonable, but another potential definition would be to only consider neighbouring vertices along out-edges (not in-edges), or something similar. Thanks for looking at the question! Commented Dec 7, 2015 at 12:20
• My best guess is that it's computing the cyclic clustering coefficient $C_i^{cyc}$, see p.13 of this paper. Commented Dec 11, 2015 at 0:11
• @ilian Yes, you are correct! How did you find that? Did I miss something in the documentation? Commented Dec 11, 2015 at 7:28
• @Szabolcs Done. Unfortunately, the documentation remains silent on this. My guess was based on a peek at some bug reports, looking up some common conventions and experimenting with a couple of graphs. Commented Dec 11, 2015 at 14:54

Transitioning my comment into an answer per Szabolcs

My best guess is that it's computing the cyclic clustering coefficient $C_i^{cyc}$, see page 13 and earlier of Fagiolo, G., 2007. Clustering in complex directed networks. Physical Review E, 76(2), p.026107 (arXiv link) for the definition.

• As your paper,I think cannot explain the vertex 3th's cyclic clustering coefficient in this case
– yode
Commented May 28, 2016 at 9:22
• @yode I think this function converts multigraphs to simple graphs internally. Commented May 28, 2016 at 20:53
• Why are you so smart?:)
– yode
Commented May 28, 2016 at 23:32
• Do you think you could get this into the documentation? I got burnt again because I forgot that it handled directed graphs specially and I assumed it ignores edge directions ... If you think that writing to support about this would help, let me know. Commented Mar 14, 2018 at 13:49
• @Szabolcs Don't want to sound pessimistic, but I had personally reported it to the appropriate people and nothing happened, so I'm not holding my breath. Commented Mar 14, 2018 at 14:41