繁体   English   中英

如何防止 Graphviz 移动节点以容纳边缘

[英]How to prevent Graphviz from moving nodes to accomodate an edge

我正在尝试使用 Graphviz 重现下图:

在此处输入图像描述

到目前为止,这是我想出的:

digraph
{
  rankdir="LR";
  splines=polyline;

  b [shape=circle, label="", style=filled, color=gray, width=0.2, height=0.2];
  c [shape=box, label="C(s)", style=filled, color=gray, xlabel=controller];
  d [shape=box, label="P(s)", style=filled, color=gray, xlabel=plant];
  a [shape=point, color=transparent, label="a"];
  e [shape=point, color=transparent, label="e"];
  f [shape=point, color=transparent, label="f"];

  c -> d [label="u"]
  b -> c [label="e"]
  a -> b [label="r"]
  d -> e [dir=none]
  e -> f [label="y"]
  e -> b
}

这让我接近但还没有完全到达那里,因为dot似乎移动节点以适应从eb的边缘,而不是相反:

在此处输入图像描述

我如何得到它,以便从eb的边缘围绕节点弯曲而不是移动它们?

(大量的试验和错误)

  • 使用 html 记录跟踪外部 label 定位
  • e->b边的constraint=false & dir=back
  • 根据需要关闭边缘剪裁以改善边缘
digraph {
  // lines were rearranged just to simplify my comprehension
  rankdir="LR";
  splines=polyline;
  //splines=ortho;  // might work, if edges use xlabels
 
  a [shape=point, color=transparent, label="a"];
  b [shape=circle, label="", style=filled, fillcolor=gray, width=0.2, height=0.2];

  // c & d use html tables to better position exterior labels
  c [shape=plaintext label=<<TABLE BORDER="0" >
    <TR>   <TD>controller</TD>   </TR>
    <TR>   <TD border="1" port="p0" bgcolor="grey">C(s)</TD>   </TR>
    </TABLE>>];

  d [shape=plaintext label=<<TABLE BORDER="0">
    <TR>   <TD>plant</TD>   </TR>
    <TR>   <TD border="1" port="p0" bgcolor="grey">C(s)</TD>   </TR>
    </TABLE>>];
  
  e [shape=point width=.01 label=""];
  f [shape=point width=.00  label="" color=white];

  a -> b [label="r"]
  b -> c:p0 [label="e"]
  c:p0:e -> d:p0:w [label="u"]
  d:p0 -> e [dir=none headclip=false]
  e -> f [label="y" tailclip=false headclip=false]

  b -> e [dir=back constraint=false]
}

给予:
在此处输入图像描述

基于以上,不会改变:

  e -> b

进入

  e -> b [dir=none constraint=false]

IE

digraph
{
  rankdir="LR";
  splines=polyline;

  b [shape=circle, label="", style=filled, color=gray, width=0.2, height=0.2];
  c [shape=box, label="C(s)", style=filled, color=gray, xlabel=controller];
  d [shape=box, label="P(s)", style=filled, color=gray, xlabel=plant];
  a [shape=point, color=transparent, label="a"];
  e [shape=point, color=transparent, label="e"];
  f [shape=point, color=transparent, label="f"];

  c -> d [label="u"]
  b -> c [label="e"]
  a -> b [label="r"]
  d -> e [dir=none]
  e -> f [label="y"]
  e -> b [dir=none constraint=false]
}

如上: http://www.webgraphviz.com/

我得到:

在此处输入图像描述

(缺点是我们在标记为y的行处仍然有一个小间隙)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM