简体   繁体   English

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

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

I'm trying to reproduce the following figure using Graphviz:我正在尝试使用 Graphviz 重现下图:

在此处输入图像描述

Here's what I came up with so far:到目前为止,这是我想出的:

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
}

This gets me close but not quite there yet, as dot seems to move the nodes to accomodate the edge from e to b and not the other way round:这让我接近但还没有完全到达那里,因为dot似乎移动节点以适应从eb的边缘,而不是相反:

在此处输入图像描述

How do I get it so that the edge from e to b bends around the nodes rather than displacing them?我如何得到它,以便从eb的边缘围绕节点弯曲而不是移动它们?

(lots of trial-and-error) (大量的试验和错误)

  • used html records to contrail external label positioning使用 html 记录跟踪外部 label 定位
  • constraint=false & dir=back for e->b edge e->b边的constraint=false & dir=back
  • turned off edge clipping as needed to improve edges根据需要关闭边缘剪裁以改善边缘
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]
}

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

Based on the above, wouldn't changing:基于以上,不会改变:

  e -> b

into进入

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

ie 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]
}

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

I get:我得到:

在此处输入图像描述

(Disadvantage we still have a small gap at the line labeled y ). (缺点是我们在标记为y的行处仍然有一个小间隙)。

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

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