GraphViz Node Placement and Rankdir

白昼怎懂夜的黑 提交于 2019-11-27 17:30:56

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:

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 group 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.

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];
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!