GraphViz - 如何使子图包含形状?

时间:2014-04-18 22:42:59

标签: graphviz dot digraphs

我有一个图表,代表一个由两个较小的流程组成的大型流程。每个较小的过程由子图表示。但是当我将其中一个子进程的末尾(比如说“一个”)连接到另一个进程的开头(“两个”)时,另一个进程(“两个”)的起始形状最终在与结束“一”。如何从一个箭头指向箭头指向两个箭头的开头,但是在其群集中保持两个的起始形状?

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成为蓝色有界框内的顶级节点。

this graph

1 个答案:

答案 0 :(得分:7)

这种情况正在发生,因为第一个子图中的行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;
}

Node in the desired subgraph