How do I force straight edges in a (simple) Digraph?

自闭症网瘾萝莉.ら 提交于 2021-01-28 10:23:41

问题


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:

Resulting graph

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


回答1:


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:



来源:https://stackoverflow.com/questions/50907121/how-do-i-force-straight-edges-in-a-simple-digraph

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!