When switching from "normal" subgraphs to clusters, rank=same doesn't apprear to work anymore.
To show my problem, please have a look at the following example graph.
digraph INV_X1 {
rankdir = "LR";
edge [penwidth="2"];
/* Component styles */
M_i_0 [shape=none;image="res/nmos.jpg"];
M_i_1 [shape=none;image="res/pmos.jpg"];
/* Node styles */
A [style=filled;color=green];
ZN [style=filled;color=green];
/* Connections */
M_i_0:n -> ZN;
A -> M_i_0:w;
/* Put M_i_0 and _VSS_0 on the same rank. */
subgraph g_VSS_0 {
rank=same;
label="_VSS_0";
_VSS_0 [shape=none;image="res/gnd.jpg";label=""];
M_i_0 -> _VSS_0 [arrowhead=none];
}
M_i_1:s -> ZN;
A -> M_i_1:w;
/* Put M_i_1 and _VDD_1 on the same rank. */
subgraph g_VDD_1 {
rank=same;
label="_VDD_1";
_VDD_1 [shape=none;image="res/pwr.jpg";label=""];
_VDD_1 -> M_i_1 [arrowhead=none];
}
}
The output is shown in the following picture. I hope it's not too confusing as I used some images for nodes. I created two subgraphs to group two nodes each and put them on the same rank. One subgraph is at the center top, the other on the center bottom.
Now I want to switch from subgraphs to clusters to make sure that the grouped nodes are always placed close to one another, and I want to have borders and labels to make the clusters visible. But when I just change the subgraph names to "cluster_..." it looks like this.
What is the problem here? Why is rank=same no longer working as expected? Also the given port position is no longer working as expected (edge is no longer connected on the south/north of the node).
I tried to pull rank=same out of the cluster into an own statement but that seems to completely overwrite the previous cluster statement as border and labels disappear. Also, I tried to use constraint=false on the node connections but that messes up the node order so I wasn't really satisfied with that approach.
Any help is appreciated. You can find the used images here if you want to recreate the graph.


