我有一张图表,表示由两个较小的过程组成的一个大过程。每个较小的过程都由一个子图表示。但是当我将这些子流程之一(假设“一个”)的结尾连接到另一个(“两个”)的开头时,另一个流程(“两个”)的起始形状最终与“一个”的结尾。我怎样才能让箭头从一个的末端指向两个的开始,但在其簇内保持两个的起始形状?
digraph BigProcess {
graph [ label="Some big process" ]
subgraph clusterSubProcess1 {
graph [ label="Subprocess one", color="red" ]
start1_1 -> start1_2;
start1_2 -> start1_3a;
start1_2 -> start1_3b;
start1_3a -> start1_4;
start1_3b -> start1_5;
start1_4 -> start1_1;
start1_5 -> start2_1;
}
subgraph clusterSubProcess2 {
graph [ label="Subprocess two", color="blue" ]
start2_1 -> start2_2;
start2_2 -> start2_3a;
start2_2 -> start2_3b;
start2_3a -> start2_4;
start2_3b -> start2_5;
start2_4 -> start2_1;
start2_5 -> end1;
}
}
这导致以下结果,我真的希望 start2_1 成为蓝色有界框内的顶部节点。
最佳答案
这是因为 start1_5 -> start2_1;
行在第一个子图中定义 start2_1
在那个子图中。您需要定义 start1_5
在第一个子图中,但在定义 start2_1
之前保持未连接状态在第二个子图中。
digraph BigProcess {
graph [ label="Some big process" ]
subgraph clusterSubProcess1 {
graph [ label="Subprocess one", color="red" ]
start1_1 -> start1_2;
start1_2 -> start1_3a;
start1_2 -> start1_3b;
start1_3a -> start1_4;
start1_3b -> start1_5;
start1_4 -> start1_1;
start1_5;
}
subgraph clusterSubProcess2 {
graph [ label="Subprocess two", color="blue" ]
start2_1 -> start2_2;
start2_2 -> start2_3a;
start2_2 -> start2_3b;
start2_3a -> start2_4;
start2_3b -> start2_5;
start2_4 -> start2_1;
start2_5 -> end1;
}
//Now connect the nodes in the two different subgraphs
start1_5 -> start2_1;
}
关于GraphViz - 如何使子图包含形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23163502/