Turns an as_dag() dag into a dag_layout, the plain data that
dag_layers() and ggplot_dag() draw from. Coordinates are in
dagviz's SVG pixel space, with y growing downward (dag_theme()
reverses the y scale to match).
Usage
dag_layout(dag, style = style_metro())Arguments
- dag
- style
A
style_metro()object.
Value
A dag_layout: a classed list of
nodes: one row per node, in row order -name,label,row,col,x,y,color_index, plus thedag's extra node columns. Those can't be namedrow,col,x,yorcolor_index: the layout needs these, so such a column is an error.segments: straight lines,layer("leader","vline","bridge"or"hline"),x,y,xend,yend,from,toandorder(dagviz's draw order, shared witharcs).arcs: one point path per arc (id), withx,y,from,toandorder.labels:name,label,x,y.edge_paths: one full point path per graph edge -from,to,piece("vline","arc"or"hline"),x,y, andorder(point order along the path) - used foredge_colorother than"source", for anyedge_width, and for highlighting paths.edges: thedag'sedgesas they are -from,to, plus any extra edge columns, such as thenofdag_collapse(), whichedge_widthofdag_layers()can name. (They are kept apart fromedge_paths, so that no column of yours can overwrite a coordinate there.)viewbox: a list ofleft,top,bottom,right,widthandheight.style: thestyle_metro()object.
Examples
dag <- as_dag(data.frame(from = c("a", "a", "b"), to = c("b", "c", "c")))
lay <- dag_layout(dag, style_metro())
print(lay)
#> <dag_layout> 3 nodes, 3 edges, 2 columns
lay$nodes
#> name label row col x y color_index
#> 1 a a 0 0 55 15 0
#> 2 b b 1 -1 35 35 1
#> 3 c c 2 -1 35 55 2