Please load the following function:
weight.community <- function(row,membership,weigth.within,weight.between) {
if(as.numeric(membership[which(names(membership)==row[1])])==as.numeric(membership[which(names(membership)==row[2])])){
weight=weigth.within
}else{
weight=weight.between
}
return(weight)
}
dump(weight.community,"weight.community.R")
source("weight.community.R")
Now, here is my issue: with igraph<1.0.0
, the following commands:
g=erdos.renyi.game(10,0.5)
V(g)$names=as.character(1:10)
membership=c(rep(1,5),rep(2,5))
names(membership)=V(g)$names
E(g)$weight=apply(get.edgelist(g),1,weight.community,membership,50,1)
g$layout=layout.fruchterman.reingold(g,weights=E(g)$weight)
plot(g)
used to give me a graph where vertices were grouped based on community membership (like shown in this thread). But in the new version of igraph, it seems that layout.fruchterman.reingold
is not responsive to edge weights anymore. I tried the new function name layout_with_fr
, with the same outcome. And the same thing happens with layout.kamada.kawai
.
I know from these release notes that
Fruchterman-Reingold and Kamada-Kawai layout algorithms rewritten from scratch
So, that might explain me running into trouble. I would appreciate any guidance on how to approach this issue.