Search code examples
graphviz

Graphviz: Force / leapfrog "column" for box


I would like to recreate the petroleum product tree with graphviz.

prototype

For this I'm glad with graphviz possibility to create a graph structured in columns.

My graph

But how can I force a box to be rendered in the 3rd instead of the 2nd column without using an empty box as bypass?


Solution

  • I did a small experiment, important part is rank=same:

    digraph g {
    
    rankdir=LR
    
    node [shape=box ]
    Petroleum
    {rank=same Benzene;Xylene;Butanes}
    {rank=same Ethylbenzene;Cyclobenzene;Cumene;"p-Xylene";Toluene}
    
    Petroleum -> Benzene
    Petroleum -> Xylene
    Petroleum -> Butanes
    Petroleum -> Toluene
    Benzene -> Ethylbenzene
    Benzene -> Cyclobenzene
    Benzene -> Cumene
    Xylene -> "p-Xylene"
    
    }