【问题标题】:When rankdir is LR, why are the nodes in the same rank ordered bottom to top instead of top to bottom?当rankdir为LR时,为什么同一rank的节点是从下到上而不是从上到下?
【发布时间】:2019-10-09 14:03:58
【问题描述】:

在以下示例中,子图中的节点从下到上排序,而不是从上到下排序。怎么能颠倒过来,从左上角开始,子图中的节点从上到下排序(A1-A4和B1-B4)?

digraph ab
{
  rankdir=LR
  splines=ortho
  ranksep=1
  node[shape = record]

  subgraph cluster_0 
  {
    label="A"
    { 
      rank = "same"
      state0_anchor [label="", style=invis, width=0]
      state0_step0 [label="A1"]
      state0_step1 [label="A2"]
      state0_step2 [label="A3"]
      state0_step3 [label="A4"]
    }
    state0_anchor->state0_step0[style = invis]
    state0_step0 -> state0_step1 -> state0_step2 -> state0_step3
  }

  state0_step3 -> state0_step0 [constraint=false]
  state0_step3 -> state1_step0 [constraint=false]

  subgraph cluster_state1 
  {
    label="B"
    { 
      rank = "same"
      state1_anchor [label="", style=invis,  width=0, height=0]
      state1_step0 [label="B1"]
      state1_step1 [label="B2"]
      state1_step2 [label="B3"]
      state1_step3 [label="B4"]
    }
    state1_anchor->state1_step0[style = invis]
    state1_step0 -> state1_step1 -> state1_step2 -> state1_step3
  }
  state1_step3 -> state0_step0 [constraint=false]

  state0_anchor -> state1_anchor[style = invis]
  start -> state0_step0
}

【问题讨论】:

标签: graphviz


【解决方案1】:

在您的示例中,当子图中的边方向反转时,节点将按照您想要的方式排序。像这样的:

state0_step3 -> state0_step2 [dir=rev]
state0_step2 -> state0_step1 [dir=rev]
state0_step1 -> state0_step0 [dir=rev]
state0_step0 -> state0_anchor [style = invis]

state1-nodes 也一样。

LR 时的转换细节可以在https://stackoverflow.com/a/9592856/63733 中找到

【讨论】:

  • 谢谢,帮了大忙!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-05-27
  • 1970-01-01
  • 2014-11-12
  • 2020-03-08
  • 2013-03-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多