如何强制子图在 Graphviz 中位于同一水平线上

How to enforce sub graphs to be on the same horizontal line in Graphviz

我正在使用 graphviz(点)生成时间扩展图以用于我的硕士论文。但是,我的绘图结果如下图:

如您所见,第三行稍微偏移到 right.I 希望所有行都在同一水平线上。我还希望每行中的 x.th 节点与其他 x.th 节点的行保持在同一水平线上。更改边缘权重对我没有帮助。

到目前为止我找不到与此问题相关的任何信息。

我想要实现的是这样的:

这是我的代码:

digraph G {
1[label="1"]
2[label="1"]
3[label="1"]
4[label="1"]
5[label="1"]
6[label="1"]
7[label="2"]
8[label="2"]
9[label="2"]
10[label="2"]
11[label="2"]
12[label="2"]
13[label="3"]
14[label="3"]
15[label="3"]
16[label="3"]
17[label="3"]
18[label="3"]
19[label="4"]
20[label="4"]
21[label="4"]
22[label="4"]
23[label="4"]
24[label="4"]

rankdir="LR";
node[width=0.15, height=0.15, shape=point];
edge[weight=500, label="1"];

1 -> 2 -> 3 -> 4 -> 5 -> 6 ;
7 -> 8 -> 9 -> 10 -> 11 -> 12 ;
13 -> 14 -> 15 -> 16 -> 17 -> 18 ;
19 -> 20 -> 21 -> 22 -> 23 -> 24 ;

edge[weight=3];
1 -> 9;
2 -> 9;
3 -> 11;

13 -> 22;
14 -> 22;
15 -> 24;

edge[weight=1];
1 -> 14;
2 -> 15;
3 -> 17;

7 -> 21;
8 -> 23;
9 -> 22;
}

如有任何帮助,我们将不胜感激。

据我所知,唯一的方法是为每个单独的节点指定一个明确的位置。

参见:How to force node position (x and y) in graphviz

尝试对从一个 "line" 到另一个 "line" 的所有边使用属性 constraint=false,而不是使用 weight

constraint 设置为 false 会使 graphviz 在布置图形节点时考虑这些边。

另请参阅此