gpt4 book ai didi

graphviz - Graphviz 中的布局

转载 作者:行者123 更新时间:2023-12-01 07:43:59 28 4
gpt4 key购买 nike

基本问题是如何控制 Graphviz 图中元素的垂直和水平定位。

考虑这个图表的摘录(在 wysiwig 编辑器中创建)。

我试图在 Graphviz 中重现它,以确定它是否适合我的目的。

digraph G {
compound=true;
node [shape=box];
edge [dir=none];
subgraph cluster_tmk_web6 {
nginx [label="nginx-frontend TCP 0.0.0.0:80"];

subgraph clusteradminapp {
unicorn [label="unicorn_rails TCP 127.0.0.1:8080"];
subgraph clusterROR {
label="ROR v.2.1";
brida [label="brida_face_client"];
}
label="Admin App";
}

memcached [label="memcached"];
sphinx;
mongodb;

subgraph cluster_errbit {
unicorn2;
ror3;
}

label="tmk-web6.service.home";
}

nginx -> unicorn;
memcached -> brida [lhead=clusterROR];


}

结果就像

我省略了一些箭头,但定位对我来说至关重要。如何将“memcached”和“sphinx”移动到集群底部?如何将'mongodb'向右移动?最后,该图将由大约 6 到 10 个这种大小的集群组成。我如何控制布局,将一些集群排成一行,将其他集群放置在上方和下方?我想我应该在这里使用“等级”属性,但不确定如何使用。请帮忙。

最佳答案

只需添加剩余的边(和两个不可见的边),graphviz 输出就更接近您想要的结果:

digraph G {
compound=true;
node [shape=box];
edge [dir=none];
subgraph cluster_tmk_web6 {
nginx [label="nginx-frontend TCP 0.0.0.0:80"];

subgraph clusteradminapp {
unicorn [label="unicorn_rails TCP 127.0.0.1:8080"];
subgraph clusterROR {
label="ROR v.2.1";
brida [label="brida_face_client"];
}
unicorn -> brida[style=invis];
label="Admin App";
}

memcached [label="memcached"];
sphinx;
mongodb;

subgraph cluster_errbit {
unicorn2;
ror3;
unicorn2 -> ror3[style="invis"];
label="Errbit";
}

label="tmk-web6.service.home";
}

nginx -> unicorn;
nginx -> unicorn2;
brida -> memcached [lhead=clusterROR];
brida -> sphinx [lhead=clusterROR];
ror3 -> mongodb;
}

添加一些颜色等,你就快完成了。

但请记住,Graphviz 不是一个所见即所得的工具——它的强项是 自动 节点布局。

关于graphviz - Graphviz 中的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6595588/

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