如何在(简单的)有向图中强制笔直的边缘? [英] How do I force straight edges in a (simple) Digraph?

查看:65
本文介绍了如何在(简单的)有向图中强制笔直的边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下简单的图:

  digraph clientproxyserver {客户"->代理" [label =来自客户的请求"];代理"->服务器" [label =转发的请求"];服务器"->"Proxy" [label =来自服务器的响应"];代理"->客户" [label =转发的响应"];} 

运行此槽:

  dot -Grankdir = LR -Nshape = box -Nheight = 1 -Tpng -ocps.png cps.gv 

我得到以下结果:

我该怎么做才能使两个底部边缘成为直线?

解决方案

通常是

以我的经验, ortho 样条曲线很少会产生令人满意的结果.

另一种选择是使用 splines = polyline :

I have the following 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" ];
}

Running this trough dot:

dot -Grankdir=LR -Nshape=box -Nheight=1 -Tpng -ocps.png cps.gv

I get the following result:

What can I do to make the two bottom edges straight lines?

解决方案

That's what usually the option splines=ortho is for:

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" ];
}

Unfortunately, the placement of the edges/labels is very confusing:

In my experience, ortho splines produce rarely a satisfying result.

An other option would be to use splines=polyline:

这篇关于如何在(简单的)有向图中强制笔直的边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆