我正在尝试制作一个图表{C1; C2}垂直对齐。与{A; B; C}和{E1; E2; E3}
相同到目前为止,这是我的代码:
digraph G{
rankdir="LR";
S -> C1 [label="150"];
S -> C2 [label="130"];
C1 -> A [label="70"];
C1 -> B [label="80"];
C2 -> B [label="60"];
C2 -> C [label="70"];
C -> B [label="10"];
A -> E1 [label="70"];
B -> E1 [label="80"];
B -> D [label="70"];
C -> E3 [label="60"];
D -> E1 [label="40"];
D -> E2 [label="0"];
D -> E3 [label="30"];
E1 -> t [label="190"];
E2 -> t [label="0"];
E3 -> t [label="90"];
}
答案 0 :(得分:1)
{ rank = same; }
是你的朋友。我在A,B和C之间添加了不可见的边缘以使它们更加紧密,并且在orde中反转了一个连接以使A超过B而不是C等。
digraph G
{
rankdir="LR";
{ rank = same; C1 C2 }
{ rank = same; A -> B -> C[ style = invis ] }
{ rank = same; E1 E2 E3 }
S -> C1 [label="150"];
S -> C2 [label="130"];
C1 -> A [label="70"];
C1 -> B [label="80"];
C2 -> B [label="60"];
C2 -> C [label="70"];
B -> C [dir = back, label="10"]; // to keep B above C
A -> E1 [label="70"];
B -> E1 [label="80"];
B -> D [label="70"];
C -> E3 [label="60"];
D -> E1 [label="40"];
D -> E2 [label="0"];
D -> E3 [label="30"];
E1 -> t [label="190"];
E2 -> t [label="0"];
E3 -> t [label="90"];
}
产量