如何在Graphviz中垂直对齐子图群集?

时间:2019-09-05 21:20:03

标签: graphviz dot

有人知道如何垂直对齐这些子图吗?

digraph G {
  rankdir=LR;
  node [shape=record, style=rounded, fontname="Arial"];
  subgraph cluster1 {
    label = "Group 1";
    rank=same;
    A [label="A1|A2"]
    A -> B -> C -> D [constraint=false];
    style = "dashed";
  }

  subgraph cluster2 {
    label = "Group 2";
    rank=same;
    Z -> Y -> X -> W [dir=back, constraint=false];
    style = "dashed";
  }

  D -> Z;
}

我想将第2组上移到第1组的中心。 enter image description here

使用此代码几乎可以做到这一点,但仍然没有对齐:

digraph G {
  rankdir=LR;
  node [shape=record, style=rounded, fontname="Arial"];

  subgraph cluster1 {
    group=g1;
    label = "Group 1";
    rank=same;
    A [label="A1|A2"];
    A -> B -> C -> D [constraint=false];
    style = "dashed";
  }

  subgraph cluster2 {
    group=g2;
    label = "Group 2";
    rank=same;
    Z -> Y -> X -> W [dir=back, constraint=false];
    style = "dashed";
  }

  D -> Z;

  edge[style=invis];
  A -> Z;
  D -> W;
}

第2组应移至中间。 enter image description here

0 个答案:

没有答案