I’m very new to GraphViz and dot (I only started today!), and I’m having a difficult time forcing "crossing edges" (I think that’s the term) on my first real graph. Specifically, I’m trying to show that the pins on an electrical component were out of place by one. GraphViz continues to shift one of my clusters downward to avoid crossing the lines, but I want them to cross; I want my clusters to be even and of the same-size. (I’ll work on the size part next.)
How can I force edge-crossing in GraphViz?
digraph {
rank=same
subgraph cluster_designed {
label="*As Designed*";
node [shape=square]
rankdir=TB
rank=same
Drain_design -> Gate_design -> Source_design [style=invis];
}
subgraph cluster_actual {
label="*On Chip*";
node [shape=square]
rankdir=TB
rank=same
Gate_actual -> Source_actual -> Drain_actual [style=invis];
}
Drain_design -> Drain_actual;
Gate_design -> Gate_actual;
Source_design -> Source_actual;
}
>Solution :
No simple tweak, it is very difficult to manage the position of clusters. Instead, I’d suggest using "html-like nodes" (https://graphviz.org/doc/info/shapes.html). They are fairly easy to position and seem to produce the result you want.
p.s. rank=same applies to subgraphs (not Root) and rankdir applies to Root graph (not subgraphs)
digraph {
{rank=same
t1 [shape=plaintext,label=<
<TABLE CELLSPACING="2" CELLPADDING="2" BORDER="1">
<TR><TD CELLSPACING="5" BORDER="0" CELLPADDING="0">"as designed"</TD></TR>
<TR><TD PORT="p1">Drain design</TD></TR>
<TR><TD PORT="p2">Gate design</TD></TR>
<TR><TD PORT="p3">Source design</TD></TR>
</TABLE>
>
]
t2 [shape=plaintext,label=<
<TABLE CELLSPACING="2" CELLPADDING="2" BORDER="1">
<TR><TD CELLSPACING="5" BORDER="0" CELLPADDING="0">"On Chip"</TD></TR>
<TR><TD PORT="p1">Gate Actual</TD></TR>
<TR><TD PORT="p2">Source Actual</TD></TR>
<TR><TD PORT="p3">Drain Actual</TD></TR>
</TABLE>
>
]
t1:p1 -> t2:p3
t1:p2 -> t2:p1
t1:p3 -> t2:p2
}
}

