4

I have a graph that represents one large process made up of two smaller processes. Each of the smaller processes is represented by a subgraph. But when I connect the end of one of those subprocesses (let's say "one") to the start of the other ("two"), the starting shape for the other process ("two") ends up in the same cluster as the ending of "one". How can I get the arrow from the end of one to point to the start of two, but keep the starting shape of two within its cluster?

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;

   }
}

This results in the following, where I really want start2_1 to be the top node within the blue bounded box.

this graph

Jeremy Thomerson
  • 722
  • 2
  • 8
  • 19
  • Have you tried declaring the nodes in addition to the edges? I might try putting not the edges in the cluster, but the nodes. (The edges might as well be declared outside of the clusters, i think.). Sorry im not at my computer or could give a real answer. – Erik Eidt Apr 18 '14 at 23:23

1 Answers1

8

That's happening because the line start1_5 -> start2_1; in the first subgraph is defining start2_1 in that subgraph. You need to define start1_5 in the first subgraph but leave it unconnected until after you define start2_1 in the second subgraph.

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

SSteve
  • 10,550
  • 5
  • 46
  • 72
  • Thank you! Seems so obvious now, but it's been years since I've used DOT/GraphViz and I'm just getting back into it. – Jeremy Thomerson Apr 19 '14 at 05:47
  • In fact, you can remove the single `start1_5;`, as you are already defining that node in the `start1_3b -> start1_5;` line: – juandesant Apr 24 '15 at 17:15