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

标签 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

最佳答案

这是因为 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

关于GraphViz - 如何使子图包含形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23163502/

相关文章:

java - 将方法参数更改为对象时出错(jgrapht 库)

C++ 17 为什么不删除二合字母和三合字母?

graph - 交互式替代点?

python - 找不到 GraphViz 的可执行文件 : Anaconda-3

layout - 控制graphviz(dot2tex)中节点的布局?

graphviz - 点中的星形图?

c++ - 如何使用 C++ graphviz 库将参数传递给点布局引擎?

erlang - 如何可视化Erlang gen_fsm

Graphviz 边缘不可辨别/边缘标签被覆盖

java - DirectedGraph : addVertex(Vertex<T> v), String 无法转换为 Vertex