Search code examples
rplotigraphgephi

Plot igraph network like Gephi Force Atlas 2


I have a network (igraph) with the following characteristics:

>g
IGRAPH DN-- 3370 16699 --
+ attr: name (v/c), grupo (v/n), year (v/n), grupo.freq (v/n),
  grupo.perc (v/n), vertex.frame.size (v/n), color (v/c),
  vertex.frame.color (v/c), grupo (e/n), year (e/n), color (e/c)

after make clustering have the following groups:

>table(V(g)$grupo)
   1    2    8
1516 1367  487

I have interest in a view that can highlight the relationship between groups (V(g)$grupo). I used the software Gephi with the layout Force Atlas 2 to the next image: https://i.sstatic.net/GQxyT.png

My question is, how to have a similar result in the R?

I'm using the following code:

colbar <- rainbow(length(table(V(g)$grupo)))
V(g)$color <- colbar
E(g)$color <- colbar
V(g)$vertex.frame.color <- colbar
V(g)$vertex.frame.size <- 0.1

plot.igraph(
            g,
            layout=layout.fruchterman.reingold.grid,
            vertex.label=NA,
            vertex.size=1,
            edge.lty=1,
            edge.arrow.size=0.0000001
            )

Follow the link to download the data I used in csv or in Rdata: http://www.datafilehost.com/d/855e3e86


Solution

  • A code in R to produce the Force Atlas 2 layout is available now: https://github.com/adolfoalvarez/Force-Atlas-2

    The layout is not yet developed as a package so you will need to source the code into R, and use the "igraph" package.

    The usage for this would be:

    library(igraph)
    g <- graph.ring(100)
    layout.forceatlas2(g, iterations=10000, plotstep=500)