我想在Graphviz中生成以下图形:

对于here解释的原因,这是:
digraph
{
layout=dot;
rankdir="LR";
overlap = true;
node[shape=record, height="0.4", width="0.4"];
edge[dir=none];
A; B; C; D; E; F; G; H; I;
A -> B -> C;
D -> E -> F;
G -> H -> I;
edge[constraint=false];
A -> D -> G;
subgraph clusterX
{
label="Cluster 1";
A; B;
}
subgraph clusterY
{
label="Cluster 2";
E; F; H; I;
}
}生成以下内容:

下面是some careful tweaking of the order of appearance of nodes:
F; E; I; H; D; G; A; B; C;我得到了正确的结果。
虽然这样可以工作,但我想更直接地控制节点的位置,所以我尝试切换到neato,这样我就可以使用pos强制节点位置:
graph g
{
layout=neato;
node[shape=record, height="0.4", width="0.4"];
edge[dir=none];
A [pos="1,3!"];
B [pos="2,3!"];
C [pos="3,3!"];
D [pos="1,2!"];
E [pos="2,2!"];
F [pos="3,2!"];
G [pos="1,1!"];
H [pos="2,1!"];
I [pos="3,1!"];
A -- B -- C;
D -- E -- F;
G -- H -- I;
A -- D -- G;
subgraph clusterX
{
label="Cluster 1";
A;
B;
}
subgraph clusterY
{
label="Cluster 2";
E; F; H; I;
}
}这将产生以下结果:

如何让neato在集群边界和集群内的节点之间添加填充(与dot的方式相同)?
发布于 2012-03-28 03:28:04
我讨厌成为一个扫兴的人,但我不认为固定位置和集群的neato方法会成功。
群集支持取决于布局引擎- not all engines support it to the same degree
请注意,无论好坏,聚类子图都不是点语言的一部分,而只是某些布局引擎遵守的语法约定。
Neato does not seem to be a part of the engines supporting clusters,虽然fdp确实支持neato like layout,但它支持not support fixed positions。
在上面链接的论坛条目中,ERG建议在某个时候使用gvpr脚本来实现这一点-可能不是你所想的解决方案。
顺便说一句,这个图不应该是有向图,我得到了警告,并用--替换了所有的->。
发布于 2021-07-23 16:12:27
在每个集群周围添加一个周围的集群,将其样式设置为"invis“,并将其边距设置为集群之间想要的额外空间。点文件将如下所示:
digraph
{
layout=dot;
rankdir="LR";
overlap = true;
node[shape=record, height="0.4", width="0.4"];
edge[dir=none];
A; B; C; D; E; F; G; H; I;
A -> B -> C;
D -> E -> F;
G -> H -> I;
edge[constraint=false];
A -> D -> G;
subgraph clusterX_margin
{
style=invis
margin=20.0
subgraph clusterX
{
label="Cluster 1";
A; B;
}
}
subgraph clusterY_margin
{
style=invis
margin=20.0
subgraph clusterY
{
label="Cluster 2";
E; F; H; I;
}
}
}https://stackoverflow.com/questions/9871062
复制相似问题