Matrix-like layout

I’m trying to do a layout that looks basically like this:

The idea is that there should be two rows, where each element in the upper row corresponds to an element in the lower row (with a “hole” in the sequence where one element from the top row isn’t paired).

In order to get things to line up properly, I thought of:

  • having the pairs in a cluster
  • representing the hole with an invisible node
  • creating potentially invisible arrows between each node in the same row

This works out ok, except for the part where I need one arrow from the bottom row to the top row. This takes a decidely roundabout way, in order to avoid overlapping with the invisible node.

Is there a cleaner, more satisfying way of achieving what I’m trying to do? Here’s the DOT for reference:

digraph {


    subgraph cluster_product {


    subgraph cluster_uuid {

    subgraph cluster_lifted_seller {

    subgraph cluster_seller {

    Start -> FA

    A -> B
    B -> C[style="invis"]
    B -> FD
    C -> D[style="invis"]

    FA -> FB
    FB -> FC
    FC -> FD
    FD -> Goal

Instead of clusters, this uses rank and the group attributes to align nodes.

  • rank=same always (or almost always?) keeps nodes aligned.
  • group=xyz usually keeps nodes aligned.
  • other changes are just cosmetic.
digraph {
    node [group="upper"]  // try to keep same Y value
    Start FA FB FC FD  Goal
    node [group="lower"]  // try to keep same Y value
    A B D
    { rank=same  // keep same X value
        FA->A [style="invis"]

    { rank=same // keep same X value

    { rank=same // keep same X value

    Start -> FA -> FB -> FC -> FD -> Goal
    A -> B -> FD

That is brilliant, thank you very much!

What’s really needed is a simple layout machine that allows someone to specify how to put notes into a grid (with relative or absolute positions) and then edges are routed in that, in some way. It would be important to preserve grid alignment (and maybe uniformity) but allow enough space to route edges, possibly many edges, with labels, etc. Note that anything like that will be stress-tested by future generations, but it sounds like a good senior independent project for somebody.