gpt4 book ai didi

graphics - GraphViz - 如何连接子图?

转载 作者:行者123 更新时间:2023-12-03 04:21:05 28 4
gpt4 key购买 nike

GraphVizDOT 语言中,我试图表示一个依赖关系图。我需要能够在容器内拥有节点,并且能够使节点和/或容器依赖于其他节点和/或容器。

我使用subgraph来表示我的容器。节点链接工作得很好,但我不知道如何连接子图。

鉴于下面的程序,我需要能够使用箭头连接 cluster_1cluster_2,但我尝试过的任何操作都会创建新节点,而不是连接集群:

digraph G {

graph [fontsize=10 fontname="Verdana"];
node [shape=record fontsize=10 fontname="Verdana"];

subgraph cluster_0 {
node [style=filled];
"Item 1" "Item 2";
label = "Container A";
color=blue;
}

subgraph cluster_1 {
node [style=filled];
"Item 3" "Item 4";
label = "Container B";
color=blue;
}

subgraph cluster_2 {
node [style=filled];
"Item 5" "Item 6";
label = "Container C";
color=blue;
}

// Renders fine
"Item 1" -> "Item 2";
"Item 2" -> "Item 3";

// Both of these create new nodes
cluster_1 -> cluster_2;
"Container A" -> "Container C";
}

enter image description here

最佳答案

DOT 用户手册给出了以下示例,其中包含簇,簇之间有边:

IMPORTANT: The initial compound=true statement is required.

digraph G {
compound=true;
subgraph cluster0 {
a -> b;
a -> c;
b -> d;
c -> d;
}
subgraph cluster1 {
e -> g;
e -> f;
}
b -> f [lhead=cluster1];
d -> e;
c -> g [ltail=cluster0,lhead=cluster1];
c -> e [ltail=cluster0];
d -> h;
}

...以及节点和簇之间的边:

enter image description here

关于graphics - GraphViz - 如何连接子图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2012036/

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