I'm trying to expand upon this rectangular layout example. The goal is to generate a similar layout but with a dynamic distribution of nodes (within reason, say no more than 20 per row) along both the top and bottom. (For now, the sides will always be 3 nodes.)
My current simplified base example uses this code:
digraph {
rankdir="LR";
node [group=top];
aa -> ab -> ac -> ad -> ae -> af -> ba;
{ rank="same"; ba -> bb -> ca; }
node [group=bot];
da -> cc -> cb -> ca [ dir="back" ];
{ rank="same"; aa -> db -> da [ dir="back"]; }
}
All the SO solutions I've come across suggest using invisible nodes, but that doesn't seem practical as I'll have math out the least common multiple, space the nodes accordingly, and create an invisible edge to lock them in place. I'd like to leave that as a last resort if there aren't better options out there.
Have tried several other approaches like calculating and setting minlen
separately for each edge, playing with settings like clusterrank
, nodesep
, ranksep
, constraint
.
Any other ideas on how to equally space the nodes along the top and bottom sides of the layout?
(I'm not tied to GraphViz. Alternative software libraries are welcome. Preferably free and with a Python API.)