Graphviz:如何渲染尊重某些节点边缘连接点的图形?

发布于 2024-12-18 19:06:20 字数 866 浏览 1 评论 0原文

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

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

谁能告诉我最接近的解决方案(可能不可能做出完全相同的解决方案? )

I want to render a graph in similar layout to the following one:

wanted

I tried this:

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"];

}

which generated the following result :( Not very nice...

my

Can anyone show me the closest possible solution? (Probably it is not possible make exactly the same)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花海 2024-12-25 19:06:20

在今晚结束之前,我已经尽可能接近了:

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 =返回,但是当使用 -Gsplines=ortho 渲染时我无法使用它
  • 正如你所看到的,边缘的顺序是随机的......

As close as I got before calling it a night:

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;

}

Save the graph as edp.gv and create the image with

dot -Gsplines=none edp.gv | neato -n -Gsplines=ortho -Tpng -o edp.png

Result:

closest possible graphviz output

Some remarks:

  • I ended up putting constraint=false on all edges, and add invisible edges to have the three nodes centered
  • Usually I like to use dir=back, but I wasn't able to use this when rendering with -Gsplines=ortho
  • As you can see, the order of the edges is random...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文