How to align objects in different clusters

Hello,

I have some issues to make alignments into 2 directions.
Some parts should be aligned=LR some other not.

Here is what I want to draw:
https://www.dropbox.com/s/hulkekxgnb6mb07/3hostsinnetwork-should.PNG

But this is what I only can draw:
https://www.dropbox.com/s/thfq08f86xr88ve/3hostsinnetwork-ranklr.png
-or-
https://www.dropbox.com/s/3vcy84at5594fyx/3hostsinnetwork-noranklr.png

My code is:
digraph R {

subgraph cluster_1 {
subgraph cluster_2 { a b c }
Net1 [shape=box, fillcolor=yellow, style="rounded, filled", ratio="expand", width=9px]
Net2 [shape=box, fillcolor=red, style="rounded, filled", ratio="expand", width=9px]
Net3 [shape=box, fillcolor=blue, style="rounded, filled", ratio="expand", width=9px]
}
rankdir=LR
a -> Net1
a -> Net2
a -> Net3
b -> Net1
b -> Net2
b -> Net3

}

Is it possible to realize my graphic with GraphViz?

Chris

There are various ways to get

There are various ways to get something like what you want. The main difficulty is that node positioning in dot is done with the assumption that the edges will not be drawn over nodes. This means one needs to stick in some scaffolding. You can remove the pieces regarding node a1, but you'll end up with b's edges being collinear.

digraph {
  splines=line
  subgraph cluster1 {
    {rank=same
       a a1 [style=invis] b c
       a ->  b -> a1 -> c  [style=invis]
    }
    Net1 [shape=box, fillcolor=yellow, style="rounded, filled", width=9]
    Net2 [shape=box, fillcolor=red, style="rounded, filled", width=9]
    Net3 [shape=box, fillcolor=blue, style="rounded, filled", width=9]
    a -> Net1
    b -> Net1 [weight=10]
    a1 -> Net1 [weight=10 style=invis]
    c -> Net1
    a -> Net2
    b -> Net2
    c -> Net2
    a -> Net3
    b -> Net3
    c -> Net3
    Net1->Net2 [style=invis weight=1000]
    Net2->Net3 [style=invis weight=1000]
  }
}

If you really want nodes a, b and c closer together, that can also be done, but it would require a bit of post-processing.

 

 -

 -

Recent comments