igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] trying to translate redundancy measure for bipartite graph


From: Simone Gabbriellini
Subject: Re: [igraph] trying to translate redundancy measure for bipartite graph from python
Date: Sat, 2 Feb 2013 10:35:21 +0100

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 <address@hidden>:
>> I am trying:
>> expand.grid(neighbors(g,1))
> Try this:
>
> neis <- neighbors(g, 1)
> expand.grid(neis, neis)
>
> --
> T.
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>


-- 
Simone Gabbriellini, PhD

address@hidden, University of Bologna
mobile: +39 340 39 75 626
email: address@hidden
home: www.digitaldust.it

DigitalBrains srl
Amministratore
mobile: +39 340 39 75 626
email: address@hidden
home: www.digitalbrains.it



reply via email to

[Prev in Thread] Current Thread [Next in Thread]