6
$\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$
9
  • $\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, 2015 at 12:05
  • 1
    $\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, 2015 at 12:20
  • 2
    $\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, 2015 at 0:11
  • 1
    $\begingroup$ @ilian Yes, you are correct! How did you find that? Did I miss something in the documentation? $\endgroup$
    – Szabolcs
    Dec 11, 2015 at 7:28
  • 2
    $\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, 2015 at 14:54

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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