已排序子图Graphviz中节点的重新排序

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

我正在创建一个工作流文档,该文档确定了我们在其中拥有一些工具的位置。随着工作流程的扩展,我需要工具紧随其后。换句话说,我需要从工作流中移出两列,以便在绘制其他列之前为其他节点留出空间,使其位于与之一起使用的节点旁边。抱歉,很难解释。这是代码,下面是它现在输出的图像以及我希望它执行的操作。

digraph notebook {
  /* Pills */
  node [shape=box, style="rounded,filled", fillcolor="#d4eba7"]; pill1;  pill2; pill3; pill4; pill5

  pill1 [label="Pill 1"]
  pill2 [label="Pill 2"]
  pill3 [label="Pill 3"]
  pill4 [label="Pill 4"]
  pill5 [label="Pill 5"]

  /* Objects */
  node [shape=box, style="rounded,filled", fillcolor="#999999"]; obj1; obj2; obj3; obj4

  obj1 [label="Obj1"]
  obj2 [label="Obj2"]
  obj3 [label="Obj3"]
  obj4 [label="Obj4"]


  /* Steps */
  node [shape=box, style=filled, fillcolor="#ff9999"]; step1; step2; step3; step4; step5; step6 

  step1 [label="Step 1"]
  step2 [label="Step 2"]
  step3 [label="Step 3"]
  step4 [label="Step 4"]
  step5 [label="Step 5"]
  step6 [label="Step 6"]

  /* Tools */
  node[shape=rect, style=filled, fillcolor="#b1ddf0"]; tool1; tool2; tool3; tool4; tool5; tool6; tool7_1; tool7_2; tool8; tool9;  

  tool1 [label="Tool 1", tooltip="description..."]  
  tool2 [label="Tool 2", tooltip="description..."]  
  tool3 [label="Tool 3", tooltip="description..."]  
  tool4 [label="Tool 4", tooltip="description..."]  
  tool5 [label="Tool 5", tooltip="description..."]  
  tool6 [label="Tool 6", tooltip="description..."]  
  tool7 [label="Tool 7", tooltip="description..."]  
  tool8 [label="Tool 8", tooltip="description..."]  
  tool9 [label="Tool 9", tooltip="description..."]  
  tool10 [label="Tool 10", tooltip="description..."]  

  /* Workflow */

  subgraph subs1 {rank="same" step1 tool1 tool2}
  subgraph subs2 {rank="same" step2 tool3 tool4}
  subgraph subs3 {rank="same" step3 tool5 tool6 tool7}
  subgraph subs4 {rank="same" obj2 obj3 obj4}
  subgraph subs5 {rank="same" step4 tool8}
  subgraph subs6 {rank="same" step5 tool9}
  subgraph subs7 {rank="same" step6 tool10}
  subgraph subs8 {rank="same" pill3 pill4 pill5}

  pill1 -> obj1 -> step1 -> step2 -> step3 -> pill2
  pill2 -> obj2 -> step4 -> step5 -> pill3
  pill2 -> obj3 -> step6 -> pill4
  pill2 -> obj4 -> pill5
}

当前输出:Current Output:

Desired Output:

graphviz dot
1个回答
0
投票

不可见的节点和边缘通常用于使节点位于所需位置。您的图形只需要几个:

digraph notebook {
  /* Pills */
  node [shape=box, style="rounded,filled", fillcolor="#d4eba7"]; pill1;  pill2; pill3; pill4; pill5

  pill1 [label="Pill 1"]
  pill2 [label="Pill 2"]
  pill3 [label="Pill 3"]
  pill4 [label="Pill 4"]
  pill5 [label="Pill 5"]

  /* Objects */
  node [shape=box, style="rounded,filled", fillcolor="#999999"]; obj1; obj2; objInvis2_1 objInvis2_2;  obj3; obj4

  obj1 [label="Obj1"]
  obj2 [label="Obj2"]
  objInvis2_1 [label="" style=invis]
  objInvis2_2 [label="" style=invis]
  obj3 [label="Obj3"]
  obj4 [label="Obj4"]

  /* Steps */
  node [shape=box, style=filled, fillcolor="#ff9999"]; step1; step2; step3; step4; step5; step6 

  step1 [label="Step 1"]
  step2 [label="Step 2"]
  step3 [label="Step 3"]
  step4 [label="Step 4"]
  step5 [label="Step 5"]
  step6 [label="Step 6"]

  /* Tools */
  /* removed tool7_1 and tool7_2 ???
  node[shape=rect, style=filled, fillcolor="#b1ddf0"]; tool1; tool2; tool3; tool4; tool5; tool6; tool7_1; tool7_2; tool8; tool9;  
  */
  node[shape=rect, style=filled, fillcolor="#b1ddf0"]; tool1; tool2; tool3; tool4; tool5; tool6; tool8; tool9;  

  tool1 [label="Tool 1", tooltip="description..."]  
  tool2 [label="Tool 2", tooltip="description..."]  
  tool3 [label="Tool 3", tooltip="description..."]  
  tool4 [label="Tool 4", tooltip="description..."]  
  tool5 [label="Tool 5", tooltip="description..."]  
  tool6 [label="Tool 6", tooltip="description..."]  
  tool7 [label="Tool 7", tooltip="description..."]  
  tool8 [label="Tool 8", tooltip="description..."]  
  tool9 [label="Tool 9", tooltip="description..."]  
  tool10 [label="Tool 10", tooltip="description..."]  

  /* Workflow */

  subgraph subs1 {rank="same" step1 tool1 tool2}
  subgraph subs2 {rank="same" step2 tool3 tool4}
  subgraph subs3 {rank="same" step3 tool5 tool6 tool7}
  subgraph subs4 {rank="same" obj2 objInvis2_1 objInvis2_2 obj3 obj4}
  subgraph subs5 {rank="same" step4 tool8}
  subgraph subs6 {rank="same" step5 tool9}
  subgraph subs7 {rank="same" step6 tool10}
  subgraph subs8 {rank="same" pill3 pill4 pill5}

  pill1 -> obj1 -> step1 -> step2 -> step3 -> pill2
  pill2 -> obj2 -> step4 -> step5 -> pill3
  pill2 -> obj3 -> step6 -> pill4
  pill2 -> obj4 -> pill5

  edge [style=invis]
  node [style=invis label=""]
  pill2 -> objInvis2_1 -> tool8 -> tool9 
  pill2 -> objInvis2_2 -> toolInvis -> tool10
}

enter image description here

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