Layout functions add x
and y
vertex attributes to the graph object.
The object is modified in place, and its shallow copy is returned.
Usage
layout_random(graph)
layout_drl(graph)
layout_fruchterman_reingold(graph, grid = 2L)
layout_mds(graph, dist)
Arguments
- graph
An
igraph_ptr
object.- grid
An integer value, whether to use the (fast but less accurate) grid based algorithm; {0: GRID, 1: NOGRID, 2: AUTOGRID}.
- dist
A distance matrix.
Value
An igraph_ptr
object with vertex attributes x
and y
.
See also
Other layouts:
layout_nicely()
,
layout_reingold_tilford()
Examples
igraph_rng_seed(24601L)
g = graph_tree(5L)
layout_random(g) |> Vattr()
#> # A tibble: 5 × 2
#> x y
#> <dbl> <dbl>
#> 1 -0.298 0.544
#> 2 0.364 -0.577
#> 3 -0.338 -0.124
#> 4 -0.347 -0.209
#> 5 -0.671 0.0251
layout_drl(g) |> Vattr()
#> # A tibble: 5 × 2
#> x y
#> <dbl> <dbl>
#> 1 -12.7 -5.17
#> 2 -12.2 -5.90
#> 3 -12.9 -4.65
#> 4 -12.7 -6.55
#> 5 -11.7 -5.98
layout_fruchterman_reingold(g) |> Vattr()
#> # A tibble: 5 × 2
#> x y
#> <dbl> <dbl>
#> 1 0.225 -0.296
#> 2 -1.28 -0.235
#> 3 1.51 -0.349
#> 4 -2.16 -1.20
#> 5 -2.08 0.795
layout_mds(g, dist = distances(g)) |> Vattr()
#> # A tibble: 5 × 2
#> x y
#> <dbl> <dbl>
#> 1 0.707 -5.38e-16
#> 2 -0.354 8.32e-17
#> 3 1.77 -1.90e-17
#> 4 -1.06 -1 e+ 0
#> 5 -1.06 1.00e+ 0