R: potential issue with igraph 1.0.0 layout algorithms

霸气de小男生 提交于 2020-01-10 06:06:37

问题


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.


回答1:


This is probably a bug in the C core of igraph that was introduced in 1.0.0. If you look at the source code of layout_fr.c, you can see that the weights argument is not used anywhere in the layout functions.

Please file an issue on GitHub if you would like to get this fixed.



来源:https://stackoverflow.com/questions/31432176/r-potential-issue-with-igraph-1-0-0-layout-algorithms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!