1

I have the following graph:

digraph D {

node [
      fontname = "Arial"
      fontsize = 11
      shape = "record"
      ]

A [ label = "my_A" ]
B [ label = "my_B" ]

subgraph cluster_mg {
        label = "Main Group";
        penwidth = 1
        color = "black"

        subgraph cluster_subgroup1 {
                color = "black";
                style = dashed;
                label = "Subgroup 1"
                A
        }

        subgraph cluster_subgroup2 {
                color = "white"
                penwidth = 0;
                label = "Subgroup 2"
                B
        }
}

#A -> B
#{ rank=same A B }

}

With the last two lines commented out, it produces this figure:

enter image description here

I want to add an arrow from my_A to my_B. When I do this (by uncommenting the first commented out line) my_A and my_B are placed vertically instead of horizontally. When I set their rank to be the same, I lose the dashed outline. How can I construct the same figure as displayed here, but with a line from my_A to my_B?

Also, how can I put my_A on the left and my_B on the right?

Vincent
  • 240
  • 2
  • 10
  • Does this answer your question? [GraphViz - How to connect subgraphs?](https://stackoverflow.com/questions/2012036/graphviz-how-to-connect-subgraphs) – ggorlen May 28 '20 at 01:11
  • 1
    I appreciate your help. Unfortunately, the example did not fix my issue. I have figured it out by now though. – Vincent May 28 '20 at 03:25

1 Answers1

0

Adding

 rankdir = LR;

to the graph[] portion did what I needed:

digraph D {

graph [ rankdir = LR ]

node [
      fontname = "Arial"
      fontsize = 11
      shape = "record"
      ]

A [ label = "my_A" ]
B [ label = "my_B" ]

subgraph cluster_mg {
        label = "Main Group";
        penwidth = 1
        color = "black"

        subgraph cluster_subgroup1 {
                color = "black";
                style = dashed;
                label = "Subgroup 1"
                A
        }

        subgraph cluster_subgroup2 {
                color = "white"
                penwidth = 0;
                label = "Subgroup 2"
                B
        }
}

A -> B

}

enter image description here

Vincent
  • 240
  • 2
  • 10
  • Could you be a bit more explicit, it is from your answer unclear where exactly to place the `rankdir = LR;`. Please a complete example plus image in the answer. – albert May 28 '20 at 09:03