Hi Tamas,
now I see, that is for permutations not combinations, which is combn()...
Here's my attempt to translate the python code, it just finds
redundancy for one set of vertices:
redundancy<-function(g){
redundancy<-c()
for(i in V(g)[which(V(g)$type==FALSE)]){
overlap = 0.0
nei<-neighbors(g,i)
if(length(nei)>1){
comb<-combn(nei, 2)
for(c in seq(1:dim(comb)[2])){
unei<-neighbors(g,comb[1,c])
wnei<-neighbors(g,comb[2,c])
redund<-Reduce(union, list(unei,wnei))
redund<-Reduce(setdiff, list(redund,i))
if(length(redund)>0){
overlap <- overlap + 1
}
}
}
if(overlap > 0){
n <- length(nei)
norm<-2.0/(n*(n-1))
} else {
norm <- 1
}
redundancy<-append(redundancy, overlap*norm)
}
return(redundancy)
}
best,
Simone
2013/2/1, Tamás Nepusz <[email protected]>:
>> I am trying:
>> expand.grid(neighbors(g,1))
> Try this:
>
> neis <- neighbors(g, 1)
> expand.grid(neis, neis)
>
> --
> T.
>
>
> _______________________________________________
> igraph-help mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
--
Simone Gabbriellini, PhD
PostDoc@DISI, University of Bologna
mobile: +39 340 39 75 626
email: [email protected]
home: www.digitaldust.it
DigitalBrains srl
Amministratore
mobile: +39 340 39 75 626
email: [email protected]
home: www.digitalbrains.it
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help