[Top][All Lists]

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

[igraph] clustering coefficients for bipartite networks

From: Simone Gabbriellini
Subject: [igraph] clustering coefficients for bipartite networks
Date: Sat, 29 Jan 2011 11:46:45 +0100

Hello List,

I've asked this question some time ago for R and Gabor wrote this code to find 
a particular clustering coefficient for bipartite networks (it is also in the 
wiki R-recipes). 
I now need to implement a python version of it, but I have no clue on how to 
implement this use of apply() in python... 
I don't think I can define functions on the fly like in R (but maybe I am 
wrong), so is it wise to break the code into smaller functions and then call 
everything from the principal function (in this example of Gabor's code, called 

ccBip <- function(g) {
        neib <- get.adjlist(g)
        names(neib) <- V(g)$name
        proj <- bipartite.projection(g)
        lapply(proj, function(x) {
                el <- get.edgelist(x)
                sapply(V(x)$name, function(v) {
                        subs <- el[,1]==v | el[,2]==v
                        f <- function(un, vn) length(union(un, vn))
                        vals <- E(x)[subs]$weight / unlist(mapply(f, 
neib[el[subs,1]], neib[el[subs,2]]))

or maybe are there in python alternative ways to accomplish this task?

best regards,

reply via email to

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