output formats canon, dot, and xdot are not completely faithful to input
Steps to reproduce
Desired result (without -Tcanon):
dot -Tpng bugfile.gv >bugfile.png
Incorrect result (with -Tcanon):
dot -Tcanon bugfile.gv >bugfile.dot
. (or dot-Tdot bugfile.gv >bugfile.dot)
then dot -Tpng bugfile.dot >bugfile.canon.png
bugfile.gv:
digraph G {
subgraph clusterSurround1 {
subgraph cluster1 {
graph [color=purple]
x1 -> y1
x1 -> z1
}
subgraph cluster2 {
graph [color=pink]
x2 -> y2
x2 -> z2
subgraph cluster2a {
graph [color=blue label=C2 boss=worker]
x21 ->x22
}
}
q0 -> x2;
z2 -> x1
}
graph [label="My Cool Graph" fontcolor=red id=boss] // this line will be repositioned
}
Expected Behaviour
pretty-printed version of input, (dot and xdot formats also add positioning detail), but no semantic changes
Actual Behaviour
Root graph attributes (label, lp, fontcolor, fontsize, id, and others) can be repositioned in the canon/dot output. This can alter the semantics of the original input file. (For more info see:https://graphviz.org/faq/#FaqGraphLabel)
OS Version
Linux - 5.4.0-96-generic #109 (closed)-Ubuntu
Graphviz Version
dot - graphviz version 3.0.0~dev.20220120.0312 (20220120.0312)
Additional info
desired graph (dot -Tpng bugfile.gv >bugfile.png):
incorrect graph (dot -Tcanon bugfile.gv |dot -Tpng >bugfile.canon.png):