0

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.

Community
  • 1
  • 1
Antoine
  • 1,649
  • 4
  • 23
  • 50

1 Answers1

3

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.

Tamás
  • 47,239
  • 12
  • 105
  • 124
  • thank for this explanation, will do. Until the issue is fixed, going back to an earlier version of igraph would work, right? The problem is that I tried to install igraph `0.7.0` or `0.7.1` from http://cran.r-project.org/src/contrib/Archive/igraph but it does not seem to be compatible with R `3.2.1` – Antoine Jul 15 '15 at 14:19
  • 1
    I am sure that 0.7.1 is compatible, you just need to build it from source. – Gabor Csardi Jul 15 '15 at 14:30
  • 1
    I will (re-)add support for the weights in a sec: https://github.com/igraph/igraph/issues/839 – Gabor Csardi Jul 15 '15 at 16:10
  • thanks a lot. When it is done, where can I download the version of igraph with the fix? – Antoine Jul 15 '15 at 21:12
  • @GaborCsardi when I download igraph 0.7.0 from the archive on CRAN and do `install.packages("C:\Users\User1\Desktop\igraph_0.7.0.tar.gz",repos=NULL,type="‌​source")` to install from source, I get: `* installing *source* package 'igraph' ... ** package 'igraph' successfully unpacked and MD5 sums checked Warning: running command 'sh ./configure.win' had status 127 ERROR: configuration failed for package 'igraph'` – Antoine Jul 16 '15 at 08:33
  • and right before the error I also get the warning: `Warning: running command 'sh ./configure.win' had status 127` – Antoine Jul 16 '15 at 08:48
  • It was 0.7.1, and it has to work in general, because that was the version on CRAN, until about three week ago. You can probably even build it on win-builder.r-project.org. – Gabor Csardi Jul 16 '15 at 17:22
  • Btw. this was also fixed in the development version of igraph. – Gabor Csardi Jul 16 '15 at 17:23