This is the R implementation of the Force Atlas 2 graph layout designed for Gephi.
Switch branches/tags
Nothing to show
Clone or download
Latest commit cdbdf2c Mar 11, 2016
Failed to load latest commit information.
R Update layout.R Mar 11, 2016
man First upload Jun 12, 2015
vignettes pdf vignette Jun 12, 2015
.Rbuildignore First upload Jun 12, 2015
.gitignore First upload Jun 12, 2015
DESCRIPTION First upload Jun 12, 2015
ForceAtlas2.Rproj First upload Jun 12, 2015
NAMESPACE First upload Jun 12, 2015 Update Jun 12, 2015


This is the R implementation of the Force Atlas 2 graph layout designed for Gephi. The algorithm is detailed in:

Jacomy M, Venturini T, Heymann S, Bastian M (2014) ForceAtlas2, a Continuous Graph Layout Algorithm for Handy Network Visualization Designed for the Gephi Software. PLoS ONE 9(6): e98679


This package is not yet available in CRAN, so install it directly from Github with:

# install.packages("devtools")


After installation the package is loaded as usual with:


This implementation accepts as inputs an igraph object or a data frame. A full parameter description of the algorithm can be found in Jacomy et al, but a summary is accesible via help("layout.forceatlas2").

Among those parameters you would probably like to set the number of iterations (iterations) and how often a plot of the positions should be generated (plotstep). This is particularly useful to evaluate the convergence of the algorithm. Set plotstep=0 to suppress intermediate plots.

igraph input

For this example I will use the coappeareance network from Les Miserables, by Victor Hugo. Get more details about this data set with"miserables")

g <- nexus.get("miserables")
layout <- layout.forceatlas2(g, iterations=2000, plotstep=100)

This can be also plotted as an igraph object:

plot(g, layout=layout)

data frame input

For those not familiar with the igraph package, is possible to calculate the algorithm directly from a data frame. This data frame should consist in three columns: from, to, and weights, indicating the corresponding nodes connections and the weights.

data <-

After you have your data in that format, the application of the function is equivalent to the previous one, with one exception, the parameter directed indicating if the network is directed or not (directed = TRUE by default). In this example, the miserables is an undirected graph so we change it accordingly.

layout.forceatlas2(data, directed=FALSE, iterations = 2000, plotstep = 100)

When the input is a data frame, the output is also a data frame including the name of the nodes and positions.