Reputation: 2413
I am trying to create a flowchart with nodes in set positions. I am using invisible nodes to try and force the direction of edges. My diagram is below.
Its not quite right as I am wanting the lines coming out from node d
, and around to the edge from c
to d
to be continuous (and straight).
How can I make it so that the lines all join? Thanks
My code to reproduce
digraph g1 {
graph [splines=false];
// invisible nodes
node[fontsize=15, shape = box, width=3, height=0] ;
i1 [ style="invis"];
i2 [ style="invis"];
i3 [ style="invis"];
i4 [ style="invis"];
node[fontsize=15, color = black, shape = box, width=3, height=1] ;
a[color=blue, label="a"];
b[color=green, label="b"];
c[color=orange, label="c"];
d[color=red, label="d"] ;
{rank=same; a -> b -> c};
{rankdir = TB; c -> i1[arrowhead=none];
i1 -> d[label=" FOR EACH\n\n"];
d -> i2[arrowhead=none];
};
{rank=same; i3 -> i2[arrowhead=none] };
{rankdir = TB;
b -> i4[style="invis"];
i4 -> i3[arrowhead=none];
};
{rank=same; i4 -> i1};
}
Following Paul's comment I tried using node[fontsize=15, shape = box, label="", width=0, height=0, fixedsize=true]
which resulted in
Upvotes: 9
Views: 9012
Reputation: 7659
Using shape = points
and minlen
comes to the rescue:
digraph g1 {
graph [splines=false];
// invisible nodes
node[ shape = point, width=0, height=0] ;
i1 [ style="invis"];
i2 [ style="invis"];
i3 [ style="invis"];
i4 [ style="invis"];
node[fontsize=15, color = black, shape = box, width=3, height=1] ;
a[color=blue, label="a"];
b[color=green, label="b"];
c[color=orange, label="c"];
d[color=red, label="d"] ;
{rank=same; a -> b -> c};
c -> i1[arrowhead=none];
i1 -> d[label=" FOR EACH\n\n"];
d -> i2[arrowhead=none];
{rank=same; i3 -> i2[arrowhead=none, minlen = 7 ] };
b -> i4[style="invis"];
i4 -> i3[arrowhead=none];
{rank=same; i4 -> i1};
}
yields
Upvotes: 15