如何在(简单的)有向图中强制直边?
How do I force straight edges in a (simple) Digraph?
我有以下简单的有向图:
digraph clientproxyserver {
"Client" -> "Proxy" [ label="Request from Client" ];
"Proxy" -> "Server" [ label="Forwarded Request" ];
"Server" -> "Proxy" [ label="Response from Server" ];
"Proxy" -> "Client" [ label="Forwarded Response" ];
}
运行这个槽dot
:
dot -Grankdir=LR -Nshape=box -Nheight=1 -Tpng -ocps.png cps.gv
我得到以下结果:
怎样才能使底部的两条边成直线?
这就是选项 splines=ortho
通常用于:
digraph clientproxyserver {
rankdir=LR;
node[shape=box, height=1];
splines=ortho
"Client" -> "Proxy" [ label="Request from Client" ];
"Proxy" -> "Server" [ label="Forwarded Request" ];
"Server" -> "Proxy" [ label="Response from Server" ];
"Proxy" -> "Client" [ label="Forwarded Response" ];
}
不幸的是,edges/labels 的位置非常混乱:
根据我的经验,ortho
样条曲线很少能产生令人满意的结果。
另一种选择是使用 splines=polyline
:
我有以下简单的有向图:
digraph clientproxyserver {
"Client" -> "Proxy" [ label="Request from Client" ];
"Proxy" -> "Server" [ label="Forwarded Request" ];
"Server" -> "Proxy" [ label="Response from Server" ];
"Proxy" -> "Client" [ label="Forwarded Response" ];
}
运行这个槽dot
:
dot -Grankdir=LR -Nshape=box -Nheight=1 -Tpng -ocps.png cps.gv
我得到以下结果:
怎样才能使底部的两条边成直线?
这就是选项 splines=ortho
通常用于:
digraph clientproxyserver {
rankdir=LR;
node[shape=box, height=1];
splines=ortho
"Client" -> "Proxy" [ label="Request from Client" ];
"Proxy" -> "Server" [ label="Forwarded Request" ];
"Server" -> "Proxy" [ label="Response from Server" ];
"Proxy" -> "Client" [ label="Forwarded Response" ];
}
不幸的是,edges/labels 的位置非常混乱:
根据我的经验,ortho
样条曲线很少能产生令人满意的结果。
另一种选择是使用 splines=polyline
: