Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphViz binary tree left and right child

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;
}
like image 363
Alberto Avatar asked Feb 09 '12 17:02

Alberto


1 Answers

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;
}
like image 91
dgw Avatar answered Oct 12 '22 11:10

dgw