graphlib-dot
graphlib-dot copied to clipboard
Parse default graph attributes
Currently rankdir doesn't get attached to the graph object in graphlib-dot, but it does with graphviz:
digraph {
graph [rankdir=LR];
X -> Y;
Y -> X;
Y -> Z;
Z -> Y;
}
This doesn't seem to work for any graph attributes.
In https://github.com/dagrejs/graphlib-dot/blob/v0.6.4/lib/build-graph.js#L11, a missing graph: {}
object causes the data to be lost in handleAttrStmt. However, I'm not sure how to merge the data from defaultStack
into g.graph()
, especially when it comes to subgraphs.
A workaround could be to use
digraph {
rankdir=LR;
X -> Y;
Y -> X;
Y -> Z;
Z -> Y;
}
(demo), which is also used in some of the graphviz examples.
Another workaround is to put quotes around the names:
digraph {
"graph" [rankdir=LR]
}
becomes
digraph {
graph [rankdir=LR]
}
This works for node and edge defaults too.