different ranks for dots

I have this code:
 digraph g{
 
{rank=same; 2 ;}
{rank=same; 1;}
{rank=same; 3;}
2->3
 
}
 
this is a test code a developed to test this strangeness.
1,2,3 must have different ranks, but this code puts 1 and 2 on the same level. I can simulate this behavior with the addition of the line below:
 
1->2 [color=white, arrowhead=none]
 
anyone know a better way to achieve it?
 
thanks in advance
 

different ranks for dots

The dot layout puts nodes on different ranks if there is an edge between them, assuming you haven't specified any other constraints. If you want 3 nodes on 3 different ranks, you need to do something like
 
digraph {
1 -> 2 -> 3
}
 
If you don't want to see the edges, use  1 -> 2 -> 3 [style=invis]
Note that using {rank=same ...} specifies that all the nodes in the subgraph share the same rank, so using this with only one node in the subgraph has no effect.
 

Recent comments