layout.forceatlas2 {GephiForR} | R Documentation |
Apply ForceAtlas2 layout to a graph
Description
This function applies Jacomy et al. (2014)'s 'ForceAtlas2' layout algorithm to an igraph
object.
Usage
layout.forceatlas2(
g,
iterations = 100,
linlog = FALSE,
pos = NULL,
gravity = 1,
center = NULL,
plotstep = 10,
plotlabels = TRUE,
scalingratio = 10,
stronggravity = FALSE,
jittertol = 1
)
Arguments
g |
An |
iterations |
Integer. The number of iterations to run the algorithm. Default is 100. |
linlog |
Logical. If |
pos |
A 2-column matrix of initial positions, where the columns contain x-coordinates and y-coordinates, respectively. If |
gravity |
Numeric. The strength of the gravity force. Default is 1. Note that this is only included in calculations if |
center |
A numeric vector of length 2 specifying the center of gravity. If |
plotstep |
Integer. The number of iterations between plots. If |
plotlabels |
Logical. If |
scalingratio |
Numeric. The scaling ratio of the layout. Default is 10, in line with ‘Gephi’. |
stronggravity |
Logical. If |
jittertol |
Numeric. The tolerance for jittering nodes. Default is |
Details
This function implements Jacomy et al. (2014)'s ForceAtlas2 layout algorithm on an igraph
object.
It can handle large graphs and is particularly suitable for visualizing networks. It also includes LinLog mode and a stronger gravity feature, like ‘Gephi’.
Value
A matrix of node positions.
References
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).
doi: 10.1371/journal.pone.0098679, https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0098679.
Noack A (2009).
“Modularity clustering is force-directed layout.”
Physical Review, 79.
https://arxiv.org/pdf/0807.4052.
Examples
# Create a random graph
library(igraph)
g <- erdos.renyi.game(100, 0.05)
# Assign non-numeric row names
V(g)$name <- paste0("node", 1:vcount(g))
# Apply ForceAtlas2 layout
pos <- layout.forceatlas2(g, linlog = TRUE, iterations = 100, scalingratio = 10)
plot(g, layout = pos)