A little late, I know, but I just wanted to show an other version without having to figure out the exact positions of each node.
digraph {
splines=false;
ranksep=0.05;
node[shape=box, color=lightblue, style=filled];
A;B;C;D;E;
node[shape=none, color=none, style=solid];
i1[label="Item 1"];
i2[label="Item 2"];
i3[label="Item 3"];
node[label="", width=0, height=0];
edge[arrowhead=none, color=blue];
{rank=same; n2; n1; n3;}
n2; n1; n3;
A -> n1;
n2 -> n1 -> n3;
{rank=same; B; C;}
n2 -> B;
n3 -> C;
{rank=same; n4; D;}
B -> n4 -> D;
{rank=same; n6; n5; i1;}
D -> n5 -> i1;
n4 -> n6;
{rank=same; n7; E;}
n6 -> n7 -> E;
{rank=same; n8; i2;}
E -> n8 -> i2;
{rank=same; n9; i3;}
i2 -> n9 -> i3;
}
Straight lines are enforced by:
splines=false
- say no to splines
- invisible nodes (nodes n1, n2,... n9)
- placing nodes on the same rank with
rank=same
It's still some work to get the dot file right, but it beats imho calculating yourself the position of each node.
Output looks like this:
As long as C has no child nodes, you'd have to apply some more trickery (invisible nodes) to display it all the way to the right.
In order to get a more general solution for different graphs, some further adaptations will probably be needed (apply weight to vertical edges, or group nodes which have to be vertically aligned, or use subgraphs, ...).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…