Graphviz:从左到右排列集群,内容从上到下
Graphviz: arranging clusters left-to-right with contents top-to-bottom
我有下图,我需要 clusters/subgraphs 从左到右排列 G-H-K-M-N-O-P。每个子图的内容都很好。我该如何做到这一点?我已经尝试按照其他问题中的描述添加不可见边缘,但它没有按预期工作。
G/H 个方框需要按正确的顺序排列,但使用权重并不奏效...
下面的代码在底部呈现图像。 00/01 节点设置为可见,以显示顺序混淆的位置。
digraph {
{
edge [ style=invis ];
rank=same;
00 [ ];
01 [ ];
02 [ style=invis ];
03 [ style=invis ];
04 [ style=invis ];
05 [ style=invis ];
06 [ style=invis ];
00 -> 01 -> 02 -> 03 -> 04 -> 05 -> 06 [ weight=1000 ];
}
subgraph cluster_GG {
label="Journal litra GG 1829";
GG27 [ label="27" ];
GG112 [ label="112" ];
GG177 [ label="177" ];
GG921 [ label="921" ];
}
subgraph cluster_HH {
label="Journal litra HH 1830";
HH800 [ label="800" ];
}
subgraph cluster_KK {
label="Journal litra KK 1832";
KK262 [ label="262" ];
KK541 [ label="541" ];
KK644 [ label="644" ];
KK701 [ label="701" ];
}
subgraph cluster_MM {
label="Journal litra MM 1834";
MM113 [ label="113" ];
MM122 [ label="122" ];
MM183 [ label="183" ];
}
subgraph cluster_NN {
label="Journal litra NN 1835";
NN644 [ label="644" ];
}
subgraph cluster_OO {
label="Journal litra OO 1836";
OO47 [ label="47" ];
OO159 [ label="159" ];
OO197 [ label="197" ];
OO253 [ label="253" ];
OO1032 [ label="1032" ];
}
subgraph cluster_PP {
label="Journal litra PP 1837";
PP485 [ label="485" ];
}
GG27 -> { GG112 }
GG112 -> { GG27 GG177 KK541 }
GG177 -> { GG112 HH800 }
KK541 -> { GG112 KK644 }
KK644 -> { KK541 KK701 }
KK701 -> { KK644 MM113 }
MM113 -> { KK701 MM122 MM183 }
MM122 -> { MM113 }
MM183 -> { MM113 OO47 }
OO47 -> { MM183 OO159 }
OO159 -> { OO47 OO197 }
OO197 -> { OO159 OO253 }
OO253 -> { OO197 OO1032 }
OO1032 -> { OO253 PP485 }
KK262 [ color=blue ]
MM122 [ color=blue ]
NN644 [ color=blue ]
GG921 [ color=red ]
HH800 [ color=red ]
PP485 [ color=red ]
00 -> GG27 [ weight=100 ];
01 -> HH800 [ weight=100 ];
02 -> KK262 [ style=invis weight=100 ];
03 -> MM113 [ style=invis weight=100 ];
04 -> NN644 [ style=invis weight=100 ];
05 -> OO47 [ style=invis weight=100 ];
06 -> PP485 [ style=invis weight=100 ];
}
在这种情况下,rankdir=LR
效果更好,因为水平列更重要,排名是唯一的排序机制。可以通过出现的顺序实现与排名正交的排序,这对于复杂的图形尤其是集群来说是困难的。
digraph {
rankdir=LR;
nodesep=0.5;
edge [ constraint=false ];
subgraph cluster_GG {
label="Journal litra GG 1829";
GG921 [ label="921" ];
{
rank=same;
GG27 [ label="27" ];
GG112 [ label="112" ];
GG177 [ label="177" ];
}
GG921 -> GG27 [ constraint=true style=invis ];
GG27 -> GG112 -> GG177;
GG177 -> GG112 -> GG27;
}
subgraph cluster_HH {
label="Journal litra HH 1830";
HH800 [ label="800" ];
}
subgraph cluster_KK {
label="Journal litra KK 1832";
{
rank=same;
KK541 [ label="541" ];
KK644 [ label="644" ];
KK701 [ label="701" ];
}
KK262 [ label="262" ];
KK541 -> KK262 [ constraint=true style=invis ];
KK541 -> KK644 -> KK701;
KK701 -> KK644 -> KK541;
}
subgraph cluster_MM {
label="Journal litra MM 1834";
{
rank=same;
MM113 [ label="113" ];
MM122 [ label="122" ];
}
{
rank=same;
MM0 [ style=none ];
MM183 [ label="183" ];
}
MM113 -> MM0 [ constraint=true style=invis ];
MM122 -> MM183 [ constraint=true style=invis ];
MM113 -> MM122 -> MM113;
MM113 -> MM183 -> MM113;
}
subgraph cluster_NN {
label="Journal litra NN 1835";
NN644 [ label="644" ];
}
subgraph cluster_OO {
label="Journal litra OO 1836";
{
rank=same;
OO47 [ label="47" ];
OO159 [ label="159" ];
OO197 [ label="197" ];
OO253 [ label="253" ];
OO1032 [ label="1032" ];
}
OO47 -> OO159 -> OO197 -> OO253 -> OO1032;
OO1032 -> OO253 -> OO197 -> OO159 -> OO47;
}
subgraph cluster_PP {
label="Journal litra PP 1837";
PP485 [ label="485" ];
}
// cluster external horizontal order
GG27 -> HH800 -> KK541 [ constraint=true style=invis ];
KK262 -> MM113 [ constraint=true style=invis ];
MM0 -> NN644 -> OO47 -> PP485 [ constraint=true style=invis ];
// cluster external
GG177:e -> HH800;
GG112 -> KK541:w;
KK541 -> GG112;
KK701 -> MM113:w;
MM113 -> KK701;
MM183 -> OO47:w;
OO47 -> MM183;
OO1032 -> PP485;
KK262 [ color=blue ];
MM122 [ color=blue ];
NN644 [ color=blue ];
GG921 [ color=red ];
HH800 [ color=red ];
PP485 [ color=red ];
}
我有下图,我需要 clusters/subgraphs 从左到右排列 G-H-K-M-N-O-P。每个子图的内容都很好。我该如何做到这一点?我已经尝试按照其他问题中的描述添加不可见边缘,但它没有按预期工作。
G/H 个方框需要按正确的顺序排列,但使用权重并不奏效...
下面的代码在底部呈现图像。 00/01 节点设置为可见,以显示顺序混淆的位置。
digraph {
{
edge [ style=invis ];
rank=same;
00 [ ];
01 [ ];
02 [ style=invis ];
03 [ style=invis ];
04 [ style=invis ];
05 [ style=invis ];
06 [ style=invis ];
00 -> 01 -> 02 -> 03 -> 04 -> 05 -> 06 [ weight=1000 ];
}
subgraph cluster_GG {
label="Journal litra GG 1829";
GG27 [ label="27" ];
GG112 [ label="112" ];
GG177 [ label="177" ];
GG921 [ label="921" ];
}
subgraph cluster_HH {
label="Journal litra HH 1830";
HH800 [ label="800" ];
}
subgraph cluster_KK {
label="Journal litra KK 1832";
KK262 [ label="262" ];
KK541 [ label="541" ];
KK644 [ label="644" ];
KK701 [ label="701" ];
}
subgraph cluster_MM {
label="Journal litra MM 1834";
MM113 [ label="113" ];
MM122 [ label="122" ];
MM183 [ label="183" ];
}
subgraph cluster_NN {
label="Journal litra NN 1835";
NN644 [ label="644" ];
}
subgraph cluster_OO {
label="Journal litra OO 1836";
OO47 [ label="47" ];
OO159 [ label="159" ];
OO197 [ label="197" ];
OO253 [ label="253" ];
OO1032 [ label="1032" ];
}
subgraph cluster_PP {
label="Journal litra PP 1837";
PP485 [ label="485" ];
}
GG27 -> { GG112 }
GG112 -> { GG27 GG177 KK541 }
GG177 -> { GG112 HH800 }
KK541 -> { GG112 KK644 }
KK644 -> { KK541 KK701 }
KK701 -> { KK644 MM113 }
MM113 -> { KK701 MM122 MM183 }
MM122 -> { MM113 }
MM183 -> { MM113 OO47 }
OO47 -> { MM183 OO159 }
OO159 -> { OO47 OO197 }
OO197 -> { OO159 OO253 }
OO253 -> { OO197 OO1032 }
OO1032 -> { OO253 PP485 }
KK262 [ color=blue ]
MM122 [ color=blue ]
NN644 [ color=blue ]
GG921 [ color=red ]
HH800 [ color=red ]
PP485 [ color=red ]
00 -> GG27 [ weight=100 ];
01 -> HH800 [ weight=100 ];
02 -> KK262 [ style=invis weight=100 ];
03 -> MM113 [ style=invis weight=100 ];
04 -> NN644 [ style=invis weight=100 ];
05 -> OO47 [ style=invis weight=100 ];
06 -> PP485 [ style=invis weight=100 ];
}
在这种情况下,rankdir=LR
效果更好,因为水平列更重要,排名是唯一的排序机制。可以通过出现的顺序实现与排名正交的排序,这对于复杂的图形尤其是集群来说是困难的。
digraph {
rankdir=LR;
nodesep=0.5;
edge [ constraint=false ];
subgraph cluster_GG {
label="Journal litra GG 1829";
GG921 [ label="921" ];
{
rank=same;
GG27 [ label="27" ];
GG112 [ label="112" ];
GG177 [ label="177" ];
}
GG921 -> GG27 [ constraint=true style=invis ];
GG27 -> GG112 -> GG177;
GG177 -> GG112 -> GG27;
}
subgraph cluster_HH {
label="Journal litra HH 1830";
HH800 [ label="800" ];
}
subgraph cluster_KK {
label="Journal litra KK 1832";
{
rank=same;
KK541 [ label="541" ];
KK644 [ label="644" ];
KK701 [ label="701" ];
}
KK262 [ label="262" ];
KK541 -> KK262 [ constraint=true style=invis ];
KK541 -> KK644 -> KK701;
KK701 -> KK644 -> KK541;
}
subgraph cluster_MM {
label="Journal litra MM 1834";
{
rank=same;
MM113 [ label="113" ];
MM122 [ label="122" ];
}
{
rank=same;
MM0 [ style=none ];
MM183 [ label="183" ];
}
MM113 -> MM0 [ constraint=true style=invis ];
MM122 -> MM183 [ constraint=true style=invis ];
MM113 -> MM122 -> MM113;
MM113 -> MM183 -> MM113;
}
subgraph cluster_NN {
label="Journal litra NN 1835";
NN644 [ label="644" ];
}
subgraph cluster_OO {
label="Journal litra OO 1836";
{
rank=same;
OO47 [ label="47" ];
OO159 [ label="159" ];
OO197 [ label="197" ];
OO253 [ label="253" ];
OO1032 [ label="1032" ];
}
OO47 -> OO159 -> OO197 -> OO253 -> OO1032;
OO1032 -> OO253 -> OO197 -> OO159 -> OO47;
}
subgraph cluster_PP {
label="Journal litra PP 1837";
PP485 [ label="485" ];
}
// cluster external horizontal order
GG27 -> HH800 -> KK541 [ constraint=true style=invis ];
KK262 -> MM113 [ constraint=true style=invis ];
MM0 -> NN644 -> OO47 -> PP485 [ constraint=true style=invis ];
// cluster external
GG177:e -> HH800;
GG112 -> KK541:w;
KK541 -> GG112;
KK701 -> MM113:w;
MM113 -> KK701;
MM183 -> OO47:w;
OO47 -> MM183;
OO1032 -> PP485;
KK262 [ color=blue ];
MM122 [ color=blue ];
NN644 [ color=blue ];
GG921 [ color=red ];
HH800 [ color=red ];
PP485 [ color=red ];
}