|
From: | Stephan Schlögl |
Subject: | Re: [igraph] Bridges between clusters |
Date: | Wed, 25 Jun 2014 18:00:07 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
Hi,
thanks for the link I'm going to have a look at it soon. Here is what i came up with based on the instructions you sent me. The function takes g igraph object att the name of the vertex attribute containing the community membership mode the neigbhorhood mode c("in","out","all"), which is directly passed to igraphs neighboorhood function calc the type of calculation to be done c("membscore","expent"), where membscore (for membership score) is supposed to be the first option you suggested and expent (for expontiated entropy of the memebership score vector) which hopefully implements your second suggestion it returns a vector of the length length(V(g)) with the respective bridgeness score for each vertex. bridgeness <- function(g,att,mode="all",calc="membscore"){ require(igraph) membscore <- function(input){ nbc <- get.vertex.attribute(g, att, index=V(g)[input]) result <- subset(count(nbc[1]==nbc[2:length(nbc)]),x==TRUE)$freq/(length(nbc)-1) return(-(result-1)) } expent <- function(input){ nbc <- get.vertex.attribute(g, att, index=V(g)[input]) if(length(nbc)>1){ membv <- count(nbc[2:length(nbc)])$freq/(length(nbc)-1) result <- exp(-(sum(log(membv)*membv)))} else{result <- 0} return(result) } nbs <- neighborhood(g,1,mode=mode) result <- unlist(lapply(nbs,calc)) return(result) } It would be great if you find the time to have a look at it and tell me if it does what you recommended me to do. Thanks a lot for your help! Best, stephan On 24.06.2014 15:14, Tamás Nepusz wrote: How about using this paper by our own Dr Nepusz?That's nice Actually, the clustering algorithm described in that paper probably won't scale up to the size of the graph you are working with. However, you can probably still make use of the "bridgeness" measure by "making up" membership scores for each vertex and each cluster as follows. Let vertex i belong to cluster j with a score that corresponds to the total weight of edges connecting vertex i to members of cluster j, divided by the total weight of edges incident on vertex i. You can then either calculate "bridgeness" scores from these membership scores. On 25.06.2014 12:10, Tamás Nepusz wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |