如何在GraphViz中强制边缘弯曲?

时间:2018-08-25 04:00:54

标签: graph-theory graphviz

我一直在尝试做我认为在Graphviz中很简单的事情,就像这样:

enter image description here

我正在尝试使用Graphviz做类似的事情,这就是现在的样子:

enter image description here

如何在GraphViz中强制边缘弯曲?

到目前为止,这是我的代码:

digraph {
  graph [rankdir = LR]
  node [shape=box]
  X1;X2;a[label='X1*X2'];Y
  {X1,X2,a}->Y[arrowsize=0.5]

  X1->X2[constraint=false dir=both arrowsize=0.5] 
  X2->a[constraint=false dir=both arrowsize=0.5] 
  a->X1[constraint=false dir=both arrowsize=0.5]
}

1 个答案:

答案 0 :(得分:0)

GraphViz

我还建议通过在边缘添加limit来使用graphviz的罗盘功能:

:w

enter image description here

但是,graphviz无法为digraph { graph [rankdir = LR] node [shape=box] X1;X2;a[label="X1*X2"];Y {X1,X2,a}->Y[arrowsize=0.5] X1:w->X2:w[constraint=false dir=both arrowsize=0.5] X2:w->a:w[constraint=false dir=both arrowsize=0.5] a:w->X1:w[constraint=false dir=both arrowsize=0.5] } (afaik)调整默认端口位置。对于您的情况,我认为这就是您想要做的。

yEd

免费但非开源的gui工具yEd支持以下功能:

enter image description here

PSTricks和pst节点

如果您不介意使用LaTeX领域的某些产品,则可以使用pstricks和pst-node软件包来解决此问题:

dot - graphviz version 2.40.1 (20161225.0304)

使用% ! TEX program = pdflatex -shell-escape \documentclass{standalone} \usepackage{pstricks-add} \usepackage{auto-pst-pdf} \usepackage{pst-node} \begin{document} \begin{pspicture} \psset{linewidth=.3pt} \rput(0,3){\rnode{A}{\psframebox{\makebox[1.1cm]{$X_1$}}}} \rput(0,2){\rnode{B}{\psframebox{\makebox[1.1cm]{$X_2$}}}} \rput(0,1){\rnode{C}{\psframebox{\makebox[1.1cm]{$X_1*X_2$}}}} \rput(2,2){\rnode{D}{\psframebox{\makebox[1.1cm]{$Y$}}}} \psset{angleA=0, angleB=180, arm=0} \ncdiag[offsetB=+3pt]{->}{A}{D} \ncdiag[offsetB=+0pt]{->}{B}{D} \ncdiag[offsetB=-3pt]{->}{C}{D} \psset{offset=3pt, angle=180, linearc=.25, armB=12pt} \ncangle{<->}{A}{B} \ncangle{<->}{B}{C} \ncangle[linearc=.3333, armB=18pt]{<->}{C}{A} \end{pspicture} \end{document} 将此文档编译为pdf即可

enter image description here

Tikz

最后是tikz解决方案

$ pdflatex -shell-escape <filename>

enter image description here

相关问题