Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple linear arrangement in graphviz

I want to generate simple linear arrangements like this:

graph I'd love to recreate with graphviz

I think I am making this way too hard. I tried just hard coding the positions, but it is a little more complicated because I want splined edges.

I don't particularly care if the edges are above or below, but specifying that would be a nice feature.

like image 463
Chad Brewbaker Avatar asked Apr 07 '11 17:04

Chad Brewbaker


1 Answers

That's one of those things one may think it must be simple to do with graphviz, but in fact it's not.

Graphviz is made to minimize edge crossing, therefore it would never lay edges out as in those pictures. That's not what graphviz was made for.

But I agree it would be nice to have an option to turn off edge optimization.

You may create something like this:

rankdir=LR;
ranksep=0;
edge[style=invis];
node[shape=none, width=0.3, height=0, margin=0.02];
4->7->5->1->8->3->6->2;

edge[style=solid, constraint=false];
1:s->2:s->3:s->4:s->5:s->6:s->7:s->8:s

resulting in

graphviz output

As soon as you start using north and south ports, graphviz will try to minimize edge crossings and lead some of the edges between the nodes:

rankdir=LR;
ranksep=0.05;
edge[style=invis];
node[shape=none, width=0.3, height=0, fontsize=12, margin=0.02];
4->7->5->1->8->3->6->2;

edge[style=solid, weight=0];
1:n->2:n;
2:s->3:s->4:s;
4:n->5:n->6:n;
6:s->7:s;
7:n->8:n;

an other graphviz output

If anybody has a better approximation, please post it, I'd be interested.

like image 176
marapet Avatar answered Sep 28 '22 20:09

marapet