View source: R/layout-spring.R
| layout_spring | R Documentation |
Computes node positions with the Fruchterman-Reingold force-directed algorithm. Nodes connected by edges attract each other and all nodes repel each other. Attraction along an edge is scaled by the absolute edge weight. Duplicate edges between the same pair of nodes, in either direction, are merged by summing their weights.
layout_spring(
network,
iterations = 200,
cooling = 0.95,
repulsion = 1.5,
attraction = 1,
seed = NULL,
initial = NULL,
max_displacement = NULL,
anchor_strength = 0,
area = 1.5,
gravity = 0,
init = c("random", "circular"),
cooling_mode = c("exponential", "vcf", "linear"),
...
)
network |
A |
iterations |
Number of iterations (default: 200). |
cooling |
Factor by which the temperature is multiplied after each
iteration when |
repulsion |
Repulsion constant (default: 1.5). |
attraction |
Attraction constant (default: 1). |
seed |
Random seed for the random initial positions. NULL (default) uses the current random state. When a seed is given, the caller's random state is restored on exit. |
initial |
Optional initial coordinates, a matrix or a data frame with
columns |
max_displacement |
Maximum distance a node can move from its initial
position (default: NULL, no limit). Applies only when |
anchor_strength |
Strength of the force pulling nodes toward their
initial positions (default: 0). Higher values (for example 0.5 to 2) keep
nodes closer to their starting positions. Applies only when
|
area |
Area parameter (default: 1.5). It sets the ideal edge length
|
gravity |
Strength of the force pulling nodes toward the centroid of the layout (default: 0). Higher values (for example 0.5 to 2) give a more compact layout. |
init |
Initialization method, |
cooling_mode |
Cooling schedule. |
... |
Additional arguments (ignored). |
A data frame with columns x and y and one row per
node. The coordinates are centered on their mean and scaled by a common
factor into [0.05, 0.95], which preserves the aspect ratio of the
layout. A
network without edges returns the initial positions, and a single node is
placed at (0.5, 0.5).
layout_spring(CographNetwork$new(regulation_net), seed = 42)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.