意志あるところに道あり!
これは、ドットを使用してそれを行う方法の例です。
digraph SEQ_DIAGRAM {
graph [overlap=true, splines=line, nodesep=1.0, ordering=out];
edge [arrowhead=none];
node [shape=none, width=0, height=0, label=""];
{
rank=same;
node[shape=rectangle, height=0.7, width=2];
api_a[label="API A"];
api_b[label="API B"];
api_c[label="API C"];
}
// Draw vertical lines
{
edge [style=dashed, weight=6];
api_a -> a1 -> a2 -> a3;
a3 -> a4 [penwidth=5, style=solid];
a4 -> a5;
}
{
edge [style=dashed, weight=6];
api_b -> b1 -> b2 -> b3 -> b4;
b4 -> b5 [penwidth=5; style=solid];
}
{
edge [style=dashed, weight=6];
api_c -> c1;
c1-> c2 [penwidth=5, style=solid];
c2 -> c3 -> c4 -> c5;
}
// Draws activations
{ rank=same; a1 -> b1 [label="activate()"]; b1 -> c1 [arrowhead=normal]; }
{ rank=same; a2 -> b2 [style=invis]; b2 -> c2 [label="refund()", arrowhead=normal, dir=back]; }
{ rank=same; a3 -> b3 [arrowhead=normal, dir=back, label="place_order()"]; b3 -> c3; }
{ rank=same; a4 -> b4 [label="distribute()", arrowhead=normal]; }
{ rank=same; a5 -> b5 [style=invis]; b5 -> c5 [label="bill_order()", arrowhead=normal]; }
}
レンダリング後、次の画像が生成されます。

これがどのように達成されたかについて、いくつかの重要なヒントがあります。
- 各コンポーネントには、形状、高さ、幅のないノードのリストがあります。
- 各行は同じランクにある必要があります。そうでない場合、DOT は自動ランキングに応じてそれらを配置します。
- 物事をまっすぐにするために、すべての方向は同じです: a から b から c へ。それらのいくつかを反転させると、DOT がめちゃくちゃになります。矢印の正しい方向を実現する秘訣は、dir エッジ属性を使用することです。
- エッジの重み属性は、垂直線をまっすぐに保つために非常に重要です。彼らは最大ランクを上回っていなければなりません。ランクが 100 まで深くなる図を作成する必要がある場合、重みは少なくとも 101 でなければなりません。
- まっすぐな水平線を得るには、各ノードを同じランクに接続する必要があります。そうしないと、DOT が線を曲げます。たとえば、a1 を c1 に接続するには、a1 を b1 に、b1 を c1 に接続します。