5
$\begingroup$

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"]

Mathematica graphics

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} *)

Also asked on Wolfram Community.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Graumagier Dec 7 '15 at 12:05
  • $\begingroup$ @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! $\endgroup$ – Szabolcs Dec 7 '15 at 12:20
  • 1
    $\begingroup$ My best guess is that it's computing the cyclic clustering coefficient $C_i^{cyc}$, see p.13 of this paper. $\endgroup$ – ilian Dec 11 '15 at 0:11
  • $\begingroup$ @ilian Yes, you are correct! How did you find that? Did I miss something in the documentation? $\endgroup$ – Szabolcs Dec 11 '15 at 7:28
  • 1
    $\begingroup$ @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. $\endgroup$ – ilian Dec 11 '15 at 14:54
5
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ As your paper,I think cannot explain the vertex 3th's cyclic clustering coefficient in this case $\endgroup$ – yode May 28 '16 at 9:22
  • $\begingroup$ @yode I think this function converts multigraphs to simple graphs internally. $\endgroup$ – ilian May 28 '16 at 20:53
  • $\begingroup$ Why are you so smart?:) $\endgroup$ – yode May 28 '16 at 23:32
  • $\begingroup$ 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. $\endgroup$ – Szabolcs Mar 14 '18 at 13:49
  • $\begingroup$ @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. $\endgroup$ – ilian Mar 14 '18 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.