Wangrui
Wangrui

Reputation: 167

Draw two subgraph without connection, one under the other, in DOT?

For example:

digraph G {
rankdir = TB;
subgraph A {
a -> {a0, a1};
};

subgraph B {
b -> {b0, b1, b2};
};
};

I want to put B at the bottom of A, how to do it?

Upvotes: 2

Views: 1859

Answers (1)

dgw
dgw

Reputation: 13666

You'll have to tell graphviz that the subgraphs are not equal. One way to do it is simply to add invisible edges between the graphs:

digraph G {
  rankdir = TB;

  subgraph A {
    a -> {a0, a1};
  };

  subgraph B {
    b -> {b0, b1, b2};
  };

  a0 -> b [style=invis];
  a1 -> b [style=invis];
};

By adding two invisible edges the subgraphs are neatly aligned.

Upvotes: 1

Related Questions