交换点布局的两个部分

问题描述 投票:0回答:1

我有以下点布局

digraph {
  subgraph {
    rank=same;
    node [shape=plain] work
    node [shape=rectangle,group=work] w2
  }

  subgraph {
    rank=same;
    node [shape=plain] main
    node [shape=rectangle,group=main] m3
  }

  node [shape=rectangle,group=work] w1
  node [shape=rectangle,group=main] m1 m2
  edge [arrowhead=open] m2 -> m1 m3 -> m2 w1 -> m1 w2 -> w1 m3 -> w2
  edge [style=dashed] main -> m3 work -> w2
}

我希望图表的左侧部分(“work”标签以及“w1”和“w2”节点)位于图表的右侧部分。我想要这样的东西:

我尝试重新排序节点和子图,但我所做的任何事情都没有使图更接近我想要的。

graphviz dot
1个回答
0
投票

分为两部分:

  • 交换两列 - 使用 rank=same + 看不见的边缘
  • 移动“工作”节点 - 反转边缘的方向 (dir=back)
digraph {
  subgraph {
    rank=same;
    node [shape=plain] work
    node [shape=rectangle,group=work] w2
  }

  subgraph {
    rank=same;
    node [shape=plain] main
    node [shape=rectangle,group=main] m3
  }

  node [shape=rectangle,group=work] w1
  node [shape=rectangle,group=main] m1 m2
  edge [arrowhead=open arrowtail=open]
  m2 -> m1 m3 -> m2 w1 -> m1 w2 -> w1 m3 -> w2
  edge [style=dashed] main -> m3
  w2 -> work [dir=back]  // reversed direction of arrowhead
  {rank=same m2 w1}      // next two reverse the order of the two columns
  m2 -> w1 [style=invis] //
}

给予:

© www.soinside.com 2019 - 2024. All rights reserved.