我正在尝试使用点文件和 graphviz 对齐三个或更多子图。我认为我的问题最好用几个例子来说明:
我的第一次尝试:
digraph FutopJobFlow {
rankdir=LR;
node [shape=box]
compound=true
subgraph clusterA {label = " A ";
A -> a1;
a1 -> a2;
a2 -> a3;
}
subgraph clusterB {label = " B ";
B -> b1;
b1 -> b2;
}
subgraph clusterC {label = " C ";
C -> c1;
c1 -> c2;
}
A -> B [lhead=clusterB];
B -> C [lhead=clusterC];
X -> A [lhead=clusterA];
Y -> B [lhead=clusterB];
Z -> C [lhead=clusterC];
}
给出这个结果:
这里的各个子图看起来像我想要的,但没有对齐。因此我尝试使用命令等级:
digraph FutopJobFlow {
rankdir=LR;
node [shape=box]
compound=true
subgraph clusterA {label = " A ";
A -> a1;
a1 -> a2;
a2 -> a3;
}
subgraph clusterB {label = " B ";
B -> b1;
b1 -> b2;
}
subgraph clusterC {label = " C ";
C -> c1;
c1 -> c2;
}
{rank=same; A; B; C;}
A -> B [lhead=clusterB];
B -> C [lhead=clusterC];
X -> A [lhead=clusterA];
Y -> B [lhead=clusterB];
Z -> C [lhead=clusterC];
}
结果如下图:
这里的对齐看起来不错,但现在“A”、“B”和“C”不再位于子图中!
我尝试了几种其他方法来实现对齐,并且“A”、“B”和“C”位于各自的子图中,但没有成功。
有人可以帮忙吗?
@ Marapet - 谢谢,它现在几乎是完美的 - 当我添加“constraint=false”参数时,它看起来像这样:
Graph with constraint parameter
如果子图“A”位于“B”上方,而“B”又位于“C”上方,那就完美了。
最佳答案
在图表的第一个版本中,您可以通过添加属性 constraint=false
来禁用对 A-B 和 B-C 之间的边的节点排名的影响:
A -> B [lhead=clusterB, constraint=false];
B -> C [lhead=clusterC, constraint=false];
然后子图应该对齐。
关于alignment - 如何对齐点文件中的子图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33025639/