20

i'm trying to draw binary tree using GraphViz but i have problems about left child and right child. There is a way to force a node to be right or left child? This is my sample code:

digraph G{
5 -> 3;
5 -> 8;
3 -> 1;
3 -> 4;
8 -> 6;
8 -> 12;
}
Alberto
  • 2,881
  • 7
  • 35
  • 66

1 Answers1

24

This should do it. ordering=out means the nodes should stay in order specified in the input.

digraph G{
  graph [ordering="out"];
  5 -> 3;
  5 -> 8;
  3 -> 1;
  3 -> 4;
  8 -> 6;
  8 -> 12;
}
dgw
  • 13,418
  • 11
  • 56
  • 54