gpt4 book ai didi

graphviz - 如何在Graphviz Dot中创建从节点到子图的边?

转载 作者:行者123 更新时间:2023-12-04 15:17:53 26 4
gpt4 key购买 nike

我想创建一个看起来像这样的图形,i。 e.从节点 Manufacturer of means of production 开始的边在哪里到同名的子图。

Expected result

我为此编写了以下代码:

digraph G {
rankdir=LR;
compound=true;

graph [fontname="Liberation Mono"];
node [fontname="Liberation Mono"];
edge [fontname="Liberation Mono"];

subgraph cluster0 {
label="System components";
mmp [label="Manufacturer of means of production", shape=box];
}

subgraph cluster1 {
t1start [label="Start of tact 1", shape=point]
t1end [label="End of tact 1", shape=point ]
subgraph cluster1_mmp {
label="Manufacturer of means of production"

cluster1_1 [label="Node 1", color=white]


subgraph cluster1_1_1 {
label="Technological cycle 1"

cluster1_1_1 [label="Node 2", color=white]
}
subgraph cluster1_1_2 {
label="Technological cycle 2"

cluster1_1_2 [label="Node 2", color=white]
}
}
}

subgraph cluster2 {
label="Такт 2"
t2start [label="Start of tact 2", shape=point]
t2end [label="End of tact 2", shape=point]

}
t1end -> t2start
mmp -> cluster1_1 [ltail=cluster1_mmp];
}

如果我尝试编译此代码 ( "C:\Program Files (x86)\Graphviz2.38\bin\"dot.exe -Tpng -ograph.png graph.dot ),则会收到警告 Warning: mmp -> cluster1_1: tail not inside tail cluster cluster1_mmp .

如何修复它并使边缘进入子图?

更新 1:

您可以在下面找到预期结果的图像 - 从节点到子图(子图,而不是子图中的节点)的边。这个边缘在下图中是红色的。

Expected result

更新 2 : 更改了如下所示的代码。
digraph G {
rankdir=LR;
compound=true;

graph [fontname="Liberation Mono"];
node [fontname="Liberation Mono"];
edge [fontname="Liberation Mono"];

subgraph cluster0 {
label="System components";
mmp [label="Manufacturer of means of production", shape=box];
}

subgraph cluster1 {
t1start [label="Start of tact 1", shape=point]
t1end [label="End of tact 1", shape=point ]
subgraph cluster1_mmp {
label="Manufacturer of means of production"

testNode [label="Node 1", color=white]

subgraph cluster1_1_1 {
label="Technological cycle 1"

cluster1_1_1 [label="Node 2", color=white]
}
subgraph cluster1_1_2 {
label="Technological cycle 2"

cluster1_1_2 [label="Node 2", color=white]
}
}
}

subgraph cluster2 {
label="Такт 2"
t2start [label="Start of tact 2", shape=point]
t2end [label="End of tact 2", shape=point]

}
t1end -> t2start
mmp -> cluster1 [ltail=cluster0, lhead=cluster1, label=" "];

}

Second attempt

最佳答案

你需要改变你的最后一行

mmp -> cluster1_1 [ltail=cluster1_mmp];


mmp -> cluster1_1 [lhead=cluster1 label="           "]

然后图表按预期出现

Issue fixed

此外,如果您希望边缘从框外开始,那么您会这样做
mmp -> cluster1_1 [ltail=cluster0 lhead=cluster1 label="           "];

Box outside

编辑

最终使用的代码
digraph G {
rankdir=LR;
compound=true;

graph [fontname="Liberation Mono"];
node [fontname="Liberation Mono"];
edge [fontname="Liberation Mono"];

subgraph cluster0 {
label="System components";
mmp [label="Manufacturer of means of production", shape=box];
}

subgraph cluster1 {
t1start [label="Start of tact 1", shape=point]
t1end [label="End of tact 1", shape=point ]
subgraph cluster1_mmp {
label="Manufacturer of means of production"

cluster1_1 [label="Node 1", color=white]


subgraph cluster1_1_1 {
label="Technological cycle 1"

cluster1_1_1 [label="Node 2", color=white]
}
subgraph cluster1_1_2 {
label="Technological cycle 2"

cluster1_1_2 [label="Node 2", color=white]
}
}
}

subgraph cluster2 {
label="Такт 2"
t2start [label="Start of tact 2", shape=point]
t2end [label="End of tact 2", shape=point]

}
t1end -> t2start
mmp -> cluster1_1 [lhead=cluster1 label=" "]
}

fiddle link对于相同的

Fiddle

关于graphviz - 如何在Graphviz Dot中创建从节点到子图的边?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49813723/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com