Graphviz:如何渲染关于某些节点边连接点的图形?

时间:2011-11-29 21:52:51

标签: layout graphviz graph-drawing

我想以与下一个相似的布局呈现图形:

wanted

我试过了:

digraph EDP
{
  graph [colorscheme=paired12];
  node [label="\N", shape=box, style="rounded,filled", colorscheme=paired12, color=8, fillcolor=7, width="1.2", fontname="Arial narrow", fontsize=12];
  edge [colorscheme=paired12, color=8, fontsize=11, fontname="Arial narrow"];

  src [label="Source"];
  dst [label="Destination"];
  filter [label="Filter"];

  src -> dst [label="Encoding process"];
  src -> filter [label="a"];
  filter -> dst [label="b"];
  src -> filter [dir=back, label=c];
  filter -> dst [dir=back, label=d];
  src -> dst [dir=back, label="Decoding process"];

}

产生了以下结果:(不太好......

my

有人能告诉我最接近的解决方案吗? (可能不可能完全相同)

1 个答案:

答案 0 :(得分:9)

尽可能接近我之前的一个晚上:

digraph EDP
{
  graph [colorscheme=paired12];

  node [label="\N", shape=box, style="rounded,filled", colorscheme=paired12, color=8, fillcolor=7, width="1.2", fontname="Arial narrow", fontsize=12];
  edge [colorscheme=paired12, color=8, fontsize=11, fontname="Arial narrow"];

  src [width=3.5, label="Source"];
  dst [width=3.5, label="Destination"];
  filter [label="Filter"];

  edge[constraint=false];
  src -> dst [label="Encoding\nprocess"];
  src -> filter [label="a"];
  filter -> dst [label="b"];
  dst -> filter [label="c"];
  filter -> src [label="d"];
  dst -> src [label="Decoding\nprocess"];

  edge[style=invis, constraint=true];
  src->filter->dst;

}

将图表另存为edp.gv并使用

创建图片
dot -Gsplines=none edp.gv | neato -n -Gsplines=ortho -Tpng -o edp.png

结果:

closest possible graphviz output

一些评论:

  • 我最终将constraint=false放在所有边上,并添加不可见边以使三个节点居中
  • 通常我喜欢使用dir=back,但在使用-Gsplines=ortho
  • 进行渲染时无法使用此功能
  • 如您所见,边缘的顺序是随机的......