igraph-help
[Top][All Lists]

 From: Tadaishi Yatabe-Rodriguez Subject: Re: [igraph] triad census Date: Tue, 26 May 2015 16:41:29 +0100

Further to my previous e-mail, this is how I found the number of triangles:

conn <- array (dim = c(vcount(el.13), vcount(el.13), vcount(el.13)))

for (i in 1:length(Successor)){
for (j in 1:length(Successor[[i]])) {
for (k in (j+1):(length(Successor[[i]]))){
conn[i,j,(k-1)] <- ifelse(length(Successor[[i]]) < 2, NA,
ifelse(k > length(Successor[[i]]), NA,
ifelse(V(el.13)[Successor[[i]][j]]==V(el.13)[Successor[[i]][k]],NA,
are.connected(el.13, V(el.13)[Successor[[i]][j]], V(el.13)[Successor[[i]][k]]))))

}}}

So transitivity, as defined previously would be:

trans <- sum(conn, na.rm = T)/triplets

Could someone more experienced tell me if this is ok and the reason of the differences with triad.census in the number of triplets of the form B <- A -> C ???

Thanks!

On Tue, May 26, 2015 at 10:41 AM, Tadaishi Yatabe-Rodriguez wrote:
Hi all,

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? Here's the code

##Successors of A
Successor=list()
for (i in 1:vcount(el.13)){

Successor[[i]] <- neighbors(el.13, v=V(el.13)[i], mode = "out")

}
### Clustering of the form B <- A -> C, where also B->C

n.succ <- sapply(Successor, FUN=length)

trip <- choose(n.succ, 2)
triplets <- sum(trip)

Thanks!

--
DVM, MPVM, PhD (C)
Center for Animal Disease Modeling and Surveillance (CADMS)
Department of Medicine and Epidemiology
School of Veterinary Medicine
University of California Davis

--