local transitivity and Barrat transitivity for directed graph

I try to compare the output of local transitivity and Barrat transitivity using igragh. However, I have problems with how they are calculated for directed graph. The result seems different from what I expected.

When calculate local transitivity, the direction is ignored. I calculated the local transitivity by number of closed triads devided by all possible triads (refer to Wasserman & Faust, 1994). But the result is 0.1666667 NaN NaN 1 1, same as the output of Barrat transitivity. Can anyone kindly explain it? Thanks a lot!

Below are the codes and output.

< g_1 <- graph( edges=c(1,2,1,3,1,4,1,5,4,1,5,1,4,5), n=5, directed=T)
< transitivity(g_1, type="local", isolates = "NaN")
#[1] 0.06666667        NaN        NaN 0.33333333 0.33333333
< transitivity(g_1, type="Barrat", isolates = "NaN")
#[1] 0.1666667       NaN       NaN 1.0000000 1.0000000

Clustering coefficient calculations are supported only for simple undirected graphs. The next version of igraph will throw an error if you try to use them on something else.

Hi,

Thanks a lot for the fast reply.
Is that mean the output of clustering coefficient (i.e., local transitivity) is wrong when the graph is directed?
Is Barrat transitivity also gives wrong number for directed graphs?

Cheers,
Yi

More precisely, if the graph is directed, will the graph be treated as undirected and produce clustering coefficient or the output is just wrong?

Right now I do not recall the details that led to forbidding non-simple graphs. To be sure that your results are correct, please use only simple graphs. You can use simplify(). I will create an issue for this so it won’t be forgotten and so that we can investigate if it would be easier to support multigraphs now.


As for directed graphs:

The concept of the clustering coefficient applied to undirected graphs only, and does not generalize to the directed case in a straightforward manner. There is no generally accepted definition of the “directed clustering coefficient” in the network science community. There are a few papers suggesting multiple different kinds of generalizations. If you think that you need to count directed triangles in your graph, take a look at motifs().

The issue tracking the directed version of clustering is here: Generalization for transitivity to directed graphs · Issue #1218 · igraph/igraph · GitHub


To get the undirected clustering for directed graphs, first convert the graph to an undirected one, and once again be sure to simplify the graph afterwards.

Do not simply apply the function to a directed graph. It will not be able to just ignore edge directions correctly, as reciprocal directed edges are effectively undirected multi-edges.

OK, I found the original issue:

Yes, it may be wrong when the graph is a multigraph after ignoring edge directions.

1 Like

Note this part in the documentation:

https://igraph.org/r/doc/transitivity.html

The barrat type of transitivity does not work for graphs with multiple and/or loop edges. If you want to calculate it for a directed graph, call as.undirected with the collapse mode first.

FYI we have improved the handling of multigraphs and directed graphs in unweighted transitivity calculations. Now edge multiplicities and edge directions are correctly ignored. It will take some time before this change makes it into the R interface of igraph though.

Ref: Support multigraphs in transitivity calculations by szhorvat · Pull Request #1790 · igraph/igraph · GitHub

Brilliant! Thanks for notifying me.

Szabolcs Horvát via igraph support forum <igraph@discoursemail.com> 于2021年5月29日周六 上午10:27写道: