GraphViz 节点放置和 Rankdir

发布于 2024-12-03 19:54:57 字数 336 浏览 0 评论 0原文

我在 graphviz 上非常幸运,并且几乎能够制作每一个 我需要的图表。我正在尝试复制此内容:

http://en.wikipedia.org/wiki/File :ICS_Structure.PNG

尽我所能。该图的底部部分全部从上到下流动,我的工作正常。我无法做的是将前 3 个孩子放在下面 “事件指挥官”。他们左右分支。另外请注意前 8 个节点中的边是如何共享的。用点可以吗?我能应付一切 否则,但不是那些顶部节点。有人可以给我解决这个问题的线索吗?

I'm having very good luck with graphviz and have been able to make nearly every
graph that I need. I'm trying to duplicate this:

http://en.wikipedia.org/wiki/File:ICS_Structure.PNG

as faithfully as I can. The bottom part of that graph all flows top to bottom and I've got that working fine. What I have not been able to do is place the first 3 children right below
"Incident Commander". They branch left and right. Plus note how the edges are shared in the top 8 nodes. Is that possible with dot? I can deal with everything
else but not those top nodes. Can someone give me a clue to solve this?

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

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

发布评论

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

评论(2

浪荡不羁 2024-12-10 19:54:57

复制图形布局的两种有用技术是:

  • 不可见节点
  • 排名约束

这是对顶部节点的快速尝试:

digraph g{
ranksep=0.2;

node[shape=box3d, width=2.3, height=0.6, fontname="Arial"];
n1[label="Incident Commander"];
n2[label="Public Information\nOfficer"];
n3[label="Liaison Officer"];
n4[label="Safety Officer"];
n5[label="Operations Section"];
n6[label="Planning Section"];
n7[label="Logistics Section"];
n8[label="Finance/Admin. Section"];

node[shape=none, width=0, height=0, label=""];
edge[dir=none];
n1 -> p1 -> p2 -> p3;
{rank=same; n2 -> p1 -> n3;}
{rank=same; n4 -> p2;}
{rank=same; p4 -> p5 -> p3 -> p6 -> p7;}
p4 -> n5;
p5 -> n6;
p6 -> n7;
p7 -> n8;
}

这是结果:

dot布局顶部节点

Two useful techniques for reproducing graph layouts are:

  • Invisible nodes
  • Rank constraints

Here's a quick try for the top nodes:

digraph g{
ranksep=0.2;

node[shape=box3d, width=2.3, height=0.6, fontname="Arial"];
n1[label="Incident Commander"];
n2[label="Public Information\nOfficer"];
n3[label="Liaison Officer"];
n4[label="Safety Officer"];
n5[label="Operations Section"];
n6[label="Planning Section"];
n7[label="Logistics Section"];
n8[label="Finance/Admin. Section"];

node[shape=none, width=0, height=0, label=""];
edge[dir=none];
n1 -> p1 -> p2 -> p3;
{rank=same; n2 -> p1 -> n3;}
{rank=same; n4 -> p2;}
{rank=same; p4 -> p5 -> p3 -> p6 -> p7;}
p4 -> n5;
p5 -> n6;
p6 -> n7;
p7 -> n8;
}

And here's the result:

dot layout top nodes

安穩 2024-12-10 19:54:57

本机 Graphviz(点)渲染不支持原始中使用的器官图渲染样式。虽然它可以生成正交边(如图所示),但无法自动对边进行分组。垂直分层可以通过minlen来实现。

接受的答案有点滥用该符号,但总体上是一种合理的方法。自动化可能会很困难,推荐的所见即所得替代方案可能是最简单的。

糟糕的 ICS渲染

对所提供解决方案的更改是:

graph [splines=ortho]; edge [dir = none];

{ rank = same; n2; n3; }
n1 -> { n2; n3; };
n1 -> n4 [minlen = 2];
{ rank = same; n5; n6; n7; n8; };
n1 -> { n5; n6; n7; n8; } [minlen = 3];

The native Graphviz (dot) rendering does not support the organogram rendering style used in the original. While it can generate orthogonal edges (as shown), there is no way to automate the grouping of edges. The vertical layering can be achieved with minlen.

The accepted answer is somewhat of an abuse of the notation, but altogether a reasonable approach. It will likely be difficult to automate and the recommended WYSIWIG alternative is likely to be simplest.

poor ICS rendering

The changes to the supplied solution are:

graph [splines=ortho]; edge [dir = none];

{ rank = same; n2; n3; }
n1 -> { n2; n3; };
n1 -> n4 [minlen = 2];
{ rank = same; n5; n6; n7; n8; };
n1 -> { n5; n6; n7; n8; } [minlen = 3];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文