How to set fixed depth levels in DOT charts

I am creating a DOT graph visualization from a tree data structure, but I am having difficulty setting fixed-level depths based on the data type. For example, if I had 4 nodes in the tree, and A denotes a specific data type and B is another, it would need Graph_1:

ROOT / \ A[0] B[1] / B[0] 

unlike Graph_2:

  ROOT / \ A[0] \ / \ B[0] B[1] 

Graph_2 is what I would like to get.

Fixed levels are what I'm looking for. How can i achieve this? I can easily determine what type of data I am adding to the graph, but I am having problems with how to mark nodes to achieve this. Can this be done using subgraphs?

FYI, this is my first time playing with DOT.

+6
python graphviz dot macos
source share
1 answer

Yes, subgraphs will be executed.

 digraph { subgraph { rank = same; A0 }; subgraph { rank = same; B0; B1 }; root -> A0; A0 -> B0; root -> B1; } 

leads to

alt text http://images.brool.com/upload/graph.jpg

+3
source share

All Articles