cluster changes nodes order ??

Hi,

I am facing a strange behaviour; with the following specification, nodes are drawn, from left to right, 0 then 1:
graph "test0" {
0;
1;
}

But with a cluster, the nodes are drawn 1 then 0:
graph "test1" {
subgraph cluster0 {
graph [style=invis];
0;
1;
}
}

How could you explain that and ensure the order the nodes are drawn could be mastered ?

Thanks

This isn't the nicest answer

This isn't the nicest answer but the dot layout doesn't specify how disconnected nodes are drawn, so either order is valid. (The switch occurs because the nodes are processed as a linear list and the list order is reversed during cluster processing.)

To guarantee relative ordering, you need to provide extra constraints for dot to satisfy. This is normally done via edges, but edges also imply a top-down ordering. To prevent this, specify that 0 and 1 should lie on the same rank:

graph "test0" {
  subgraph cluster0 {
    style=invis
    {  rank=same  0 -- 1 [style=invis]
    }
  }
}