[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] triad census
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] triad census |
Date: |
Wed, 27 May 2015 22:18:14 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi,
> I'm trying to calculate transitivity of the form B <- A -> C, where also
> B->C in a directed graph. For this I counted all the neighbors looping over
> each vertex using the function neighbors(graph[i], mode='out'). Then I
> counted the number of neighbors using the function length. Finally I get
> the number of possible triplets for each vertex using combinatorial, i.e.
> choose(number.neihgbors, 2) and I got the number of triplets of the form B
> <- A -> C for each vertex. When I added them all and then compare with the
> results from triad census for the same kind of triplets results didn't
> match. Any idea why?
You have calculated the number of (A,B,C) triplets where the following
conditions hold:
- there is an edge from A to B
- there is an edge from A to C
Note that we do not know whether there is an edge from B to A, C to A, B to
C or C to B. However, when you look at the number of out-star (i.e. B <- A ->
C) triads in the triad census, this would give you the number of those triads,
where there is an edge from A to B and A to C but there is _no_ edge from B to
A, B to C, C to A or C to B. So that's why the two numbers are different.
(Footnote: you can simply do this -- it should be equivalent to what you do
now:
degs <- degree(g, mode="out")
sum(degs*(degs-1)/2)
)
As for calculating the transitivity you need, basically you need the ratio of
the number of triplets that fit the (B <- A -> C, B -> C) pattern, divided by
the
number of triplets that fit the (B <- A -> C) pattern. The numerator and the
denominator will be a sum of certain components of the triad census (see
?triad.census for the exact meaning of each component), you only need to figure
out which of the triads fit the two patterns.
T.