graphviz:“相同” - 分组框周围的虚线框

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

我有许多盒子放在同一水平上:boxes on the same level通过多个{rank=same a3 b3_1 b3_2 c3_1 c3_2 d3_1 d3_2};线,而我用a3 [label = "Assigned"];线定义我的元素。

我想在同一级别的所有元素周围找到一个(虚线的,如果可能的话)框(通过编辑器进行模拟):enter image description here


整个来源如下:

digraph customer {
layout=dot
label = "some diagram";
labelloc = "t"; // place the label at the top
node [shape=record];

{rank=same a1 b1 c1 d1};
{rank=same a2 b2 c2 d2};
{rank=same a3 b3_1 b3_2 c3_1 c3_2 d3_1 d3_2};
{rank=same a4 b4_1_1 b4_1_2 b4_2_1 b4_2_2 c4_1_1 c4_1_2 c4_2_1 c4_2_2 d4_1_1 d4_1_2 d4_2_1 d4_2_2};
{rank=same a5  b5_1 b5_2 b5_3 b5_4 c5_1 c5_2 c5_3 c5_4 d5_1 d5_2 d5_3 d5_4};
{rank=same a6  b6_1 b6_2 b6_3 b6_4 c6_1 c6_2 c6_3 c6_4 d6_1 d6_2 d6_3 d6_4};

a1 [label = "Level 1"];
a2 [label = "Level 2"];
a3 [label = "Level 3"];
a4 [label = "Level 4"];
a5 [label = "Level 5"];
a6 [label = "Level 6"];
a1 -> a2 -> a3 -> a4; a4 -> a5 [label = "case ..." ]; a5 -> a6;


b1     [label = "Text A"];
b2     [label = "false"];
b3_1   [label = "no"];
b3_2   [label = "yes"];
b4_1_1 [label = "same"];
b4_1_2 [label = "different"];
b4_2_1 [label = "same"];
b4_2_2 [label = "different"];
b5_1   [label = "no", fillcolor = red, style=filled];
b5_2   [label = "no", fillcolor = red, style=filled];
b5_3   [label = "no", fillcolor = red, style=filled];
b5_4   [label = "yes", fillcolor = green, style=filled];
b6_1   [label = "yes", fillcolor = green, style=filled];
b6_2   [label = "yes", fillcolor = green, style=filled];
b6_3   [label = "yes", fillcolor = green, style=filled];
b6_4   [label = "yes", fillcolor = green, style=filled];


b1 -> b2;
b2 -> b3_1; b3_1 -> b4_1_1; b4_1_1 -> b5_1 [label = "A" ]; b5_1 -> b6_1;
            b3_1 -> b4_1_2; b4_1_2 -> b5_2 [label = "B" ]; b5_2 -> b6_2;
b2 -> b3_2; b3_2 -> b4_2_1; b4_2_1 -> b5_3 [label = "C" ]; b5_3 -> b6_3;
            b3_2 -> b4_2_2; b4_2_2 -> b5_4 [label = "D" ]; b5_4 -> b6_4;

subgraph clusterone {
    a1; b1; c1; d1;
    label="level 1";
    graph[style=dotted];
 }

c1     [label = "Text B"];
c2     [label = "true"];
c3_1   [label = "no"];
c3_2   [label = "yes"];
c4_1_1 [label = "same"];
c4_1_2 [label = "different"];
c4_2_1 [label = "same"];
c4_2_2 [label = "different"];
c5_1   [label = "no", fillcolor = red, style=filled];
c5_2   [label = "no", fillcolor = red, style=filled];
c5_3   [label = "yes", fillcolor = green, style=filled];
c5_4   [label = "yes", fillcolor = green, style=filled];
c6_1   [label = "yes", fillcolor = green, style=filled];
c6_2   [label = "yes", fillcolor = green, style=filled];
c6_3   [label = "yes", fillcolor = green, style=filled];
c6_4   [label = "yes", fillcolor = green, style=filled];


c1 -> c2;
c2 -> c3_1; c3_1 -> c4_1_1; c4_1_1 -> c5_1 [label = "E" ]; c5_1 -> c6_1;
            c3_1 -> c4_1_2; c4_1_2 -> c5_2 [label = "F" ]; c5_2 -> c6_2;
c2 -> c3_2; c3_2 -> c4_2_1; c4_2_1 -> c5_3 [label = "G" ]; c5_3 -> c6_3;
            c3_2 -> c4_2_2; c4_2_2 -> c5_4 [label = "H" ]; c5_4 -> c6_4;


d1     [label = "(else)"];
d2     [label = "???", fillcolor = yellow, style=filled];
d3_1   [label = "no"];
d3_2   [label = "yes"];
d4_1_1 [label = "same"];
d4_1_2 [label = "different"];
d4_2_1 [label = "same"];
d4_2_2 [label = "different"];
d5_1   [label = "no", fillcolor = red, style=filled];
d5_2   [label = "no", fillcolor = red, style=filled];
d5_3   [label = "no", fillcolor = red, style=filled];
d5_4   [label = "no", fillcolor = red, style=filled];
d6_1   [label = "yes", fillcolor = green, style=filled];
d6_2   [label = "yes", fillcolor = green, style=filled];
d6_3   [label = "yes", fillcolor = green, style=filled];
d6_4   [label = "yes", fillcolor = green, style=filled];


d1 -> d2;
d2 -> d3_1; d3_1 -> d4_1_1; d4_1_1 -> d5_1 [label = "I" ]; d5_1 -> d6_1;
            d3_1 -> d4_1_2; d4_1_2 -> d5_2 [label = "J" ]; d5_2 -> d6_2;
d2 -> d3_2; d3_2 -> d4_2_1; d4_2_1 -> d5_3 [label = "K" ]; d5_3 -> d6_3;
            d3_2 -> d4_2_2; d4_2_2 -> d5_4 [label = "L" ]; d5_4 -> d6_4;
}
graphviz dot
1个回答
2
投票

由于某种原因,它与rank=same声明冲突。

尝试删除它并使用集群而不是内部的rank=same,如下所示:

subgraph cluster_one {
  label="cluster one";
  rank=same;
  style=dotted;
  a1 b1 c1 d1
};

subgraph cluster_two {
  label="cluster two";
  rank=same;
  style=dotted;
  a2 b2 c2 d2
};

甚至更短(一行):

subgraph cluster_one { label="cluster one" rank=same style=dotted a1 b1 c1 d1 }

Dot cluster example

请记住,子图的宽度将不再像过去那样相同。

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