Simple linear layout in graphics

I want to create simple linear devices like this:

graph I'd love to recreate with graphviz

I think I'm doing it too hard. I tried just hard coding the positions, but it's a little harder because I want spline edges.

I'm not really interested if the ribs are higher or lower, but indicating that this will be a nice feature.

+4
source share
1 answer

This is one of those things you might think that it should be easy to do with the schedule, but actually it is not.

Graphviz was created to minimize the intersection of edges, so it will never lie on the edge, as in these images. This is not what graphics were made for .

But I agree that it would be nice to be able to disable edge optimization.

You can 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 

as a result

graphviz output

As soon as you start using the north and south ports, graphviz will try to minimize edge intersections and bring some edges between 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 anyone has a better approximation, send it to me, I would be interested.

+6
source

Source: https://habr.com/ru/post/1347145/


All Articles