graphviz - How to pick which side a node is on in a simple binary tree? -
in simple binary tree, able make graph right adding invisible nodes , invisible edges, instance from:
digraph { vertex_1 [label="a"]; vertex_2 [label="b"]; vertex_2 -> vertex_1 [label="left"]; }
which produces:
to:
digraph { vertex_1 [label="a"]; vertex_2 [label="b"]; vertex_0 [style=invis]; vertex_2 -> vertex_1 [label="left"]; vertex_2 -> vertex_0 [style=invis]; }
which produces:
but when tried trick 4 node graph (it straight , down) here got:
digraph { vertex_1 [label="a"]; vertex_2 [label="b"]; vertex_3 [label="f"]; vertex_4 [label="g"]; vertex_01 [style=invis]; vertex_02 [style=invis]; vertex_03 [style=invis]; vertex_4 -> vertex_3 [label="left"]; vertex_3 -> vertex_1 [label="left"]; vertex_1 -> vertex_02 [style=invis]; vertex_4 -> vertex_03 [style=invis]; vertex_3 -> vertex_01 [style=invis]; vertex_1 -> vertex_2 [label="right"]; }
which produced:
obviously want b on right side of a. tried switching order of invisible edge statement , actual edge b a, 1 came first make no difference. how can tell program put specific node or edge on specific side?
for order left right node creation order relevant. left node must created before right sibling.
digraph { vertex_1 [label="a"]; vertex_02 [style=invis]; vertex_2 [label="b"]; vertex_3 [label="f"]; vertex_4 [label="g"]; vertex_01 [style=invis]; vertex_03 [style=invis]; vertex_4 -> vertex_3 [label="left"]; vertex_3 -> vertex_1 [label="left"]; vertex_1 -> vertex_02 [style=invis]; vertex_4 -> vertex_03 [style=invis]; vertex_3 -> vertex_01 [style=invis]; vertex_1 -> vertex_2 [label="right"]; }
Comments
Post a Comment