Position of clusters

I have the following graph
digraph HZ1 {
rankdir=LR
splines=Ortho
compound=true
1
1->119
119->2[lhead=clusterStation_0]
subgraph clusterStation_0{2 3 4 }
119->172
subgraph clusterStat{rank=same;119 172 }
}
The result with dot engine is attached. What I want to achieve is to have the path 119->172... on the same line, this works. Now each of these nodes has an edge to exactly one cluster. Nodes in this subcluster are aligned vertically. So far this works. Now I want to draw ONE edge to connect node with its cluster. and this edge should go straight south to have the cluster positioned under the node. This does not work for me, as you can see in the image, the cluster is not under the connected node where it belongs to, but instead under the next one.

AttachmentSize
graph.jpg10.71 KB

Works, thank you :) I would

Works, thank you :)

I would have never figured out on my own.

To get nodes 2 and 119

To get nodes 2 and 119 vertically aligned is easy. First, since you specified rankdir=LR, rows and columns switch roles. Thus, you don't need the same rank constraint for 119 and 172, but you need one for 119 and 2. Second, the default ranking function only allows one constraint per node. So a node can't be in a cluster and a same rank constraint at the same time. One of the two will be ignored, unfortunately sometimes quietly. So you need to use the new ranking function, either by adding newrank=true to your graph or running dot with -Tnewrank. This gives you:

digraph HZ1 {
newrank=true
rankdir=LR
splines=Ortho
compound=true
1->119
119->2[lhead=clusterStation_0]
subgraph clusterStation_0{2 3 4 }
119->172
{rank=same 2 119}
subgraph clusterStat{119 172 }
}

Technically, the drawing is correct, in that it satisfies all of the graph constraints, but it is not what you want. First, you have to specify the 2, 3 and 4 line on the same rank. Second, you want 2 to appear below 119. For this, we have to add an invisible, 0 weight edge from 1 to 2.

digraph HZ1 {
newrank=true
rankdir=LR
splines=ortho
compound=true
1->119
119->2[lhead=clusterStation_0]
1 -> 2 [style=invis weight=0]
subgraph clusterStation_0{rank=same 2 3 4 }
119->172
{rank=same 2 119}
subgraph clusterStat{119 172 }
}

 

 

Solved! Thank you.

Solved! Thank you.

Recent comments