R:igraph 1.0.0布局算法的潜在问题 [英] R: potential issue with igraph 1.0.0 layout algorithms

查看:89
本文介绍了R:igraph 1.0.0布局算法的潜在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请加载以下功能:

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")

现在,这是我的问题:使用igraph<1.0.0时,以下命令:

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和Kamada-Kawai布局算法从重写 从头开始

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.

推荐答案

这可能是igraph的C核心中的一个错误,该错误已在1.0.0版本中引入.如果查看layout_fr.c的源代码,可以看到weights参数在布局函数中的任何地方都没有使用.

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.

如果要解决此问题,请在 GitHub 上提交问题.

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

这篇关于R:igraph 1.0.0布局算法的潜在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆