I found multiple postings (e.g. here and here) that illustrate how to modify a layout by adding an edge weight.
Still when I do
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)
with R version 3.2.2 and igraph version 1.0.1 I got the exact same layout. What instead I would expect to obtain is a layout where edges with a higher (lower) weight are shorter (longer). In other words, nodes connected by an edge with a higher weight are relative closer to each other than nodes connected by a low-weight edge.
Am I doing something wrong?
There is/was a bug in the new Fruchterman-Reingold layout implementation (starting from igraph 1.0.0) which made it ignore the weights. This has already been fixed in the development version, but it seems like this version was not released yet. You can install the development version from Github with the devtools package:
devtools::install_github("gaborcsardi/pkgconfig")
devtools::install_github("igraph/rigraph")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With