igraph:在布局算法中指定权重

igraph: Specify weights in a layout algorithm

我发现了多个帖子(例如 here and here)说明了如何通过添加边缘权重来修改布局。

我做的时候还在

require(igraph)

g <- graph.ring(10)

plot(g)

set.seed(28100)
E(g)$weight <- sample(1:10, 10, replace = TRUE)
E(g)$weight 
# [1] 4 3 4 6 2 9 5 2 9 7
l <- layout_with_fr(g, weights=E(g)$weight)

plot(g, layout=l)

R version 3.2.2igraph version 1.0.1 我得到了完全相同的布局。相反,我希望获得的是一种布局,其中权重较高(较低)的边缘较短(较长)。换句话说,与由低权重边连接的节点相比,由具有较高权重的边连接的节点彼此相对更近。

我是不是做错了什么?

is/was 新的 Fruchterman-Reingold 布局实现(从 igraph 1.0.0 开始)中存在一个错误,导致它忽略权重。这在开发版本中有 already been fixed,但好像这个版本还没有发布。您可以使用 devtools 软件包从 Github 安装开发版本:

devtools::install_github("gaborcsardi/pkgconfig")
devtools::install_github("igraph/rigraph")