dag <- cgraph(A %-->% B, B %-->% C)
cgraph_layout(dag)
#> name x y
#> 1 A 0 0
#> 2 B 2 0
#> 3 C 4 0
cgraph_layout(dag, method = "stress")
#> name x y
#> 1 A 0.59924944 0.79995414
#> 2 B 0.02209726 -0.01703984
#> 3 C -0.62134671 -0.78291430

Compute a graph layout
Source: R/layout.R
Description
Computes node coordinates for cgraph_plot().
Usage
cgraph_layout(
x,
method = NULL,
direction = c("right", "down", "up", "left"),
seed = 1L,
...
)Arguments
x
|
A graph created with cgraph(), of any class.
|
method
|
The layout method. The default (
"sugiyama" is from NetworkLayout.jl and ignores edge direction.
|
direction
|
For "sugiyama", which way the layers flow: "right" (the default), "down", "up" or "left".
|
seed
|
For "stress", "spring" and "sfdp", the seed of the random initial positions. The layout is the same for the same seed.
|
...
|
Ignored, so that cgraph_plot() can pass its ... through.
|
Value
A data.frame with columns name, x, and y.
References
Fruchterman TMJ, Reingold EM (1991). “Graph drawing by force-directed placement.” Software: Practice and Experience, 21(11), 1129–1164. doi:10.1002/spe.4380211102.
Gansner ER, Koren Y, North S (2005). “Graph Drawing by Stress Majorization.” In Pach J (ed.), Graph Drawing (GD 2004), volume 3383 of Lecture Notes in Computer Science, 239–250. doi:10.1007/978-3-540-31843-9_25.
Hu Y (2006). “Efficient, High-Quality Force-Directed Graph Drawing.” The Mathematica Journal, 10(1), 37–71.
Sugiyama K, Tagawa S, Toda M (1981). “Methods for Visual Understanding of Hierarchical System Structures.” IEEE Transactions on Systems, Man, and Cybernetics, 11(2), 109–125. doi:10.1109/TSMC.1981.4308636.
See Also
Other plotting: cgraph_grob(), cgraph_plot(), cgraph_plot_grid(), plot-styling, plot_default_options(), plot_options()