Adding Getting titles where I want them

Here’s a simple dot file:

// Memsim
digraph {
	graph [rankdir=RL ranksep=1.5]
	node [fontsize=8 height=0.2 margin="0.02 0.02" shape=record width=0.4]
	edge [arrowsize=0.4]
	p2:2 -> frame:2 [color=blue]
	p2:3 -> frame:3 [color=blue]
	p2:4 -> frame:4 [color=blue]
	p2:5 -> frame:5 [color=blue]
	p2:6 -> frame:6 [color=blue]
	p2:7 -> frame:7 [color=blue]
	p3:0 -> frame:0 [color=green]
	p3:1 -> frame:1 [color=green]
	p3:8 -> frame:8 [color=green]
	p3:9 -> frame:9 [color=green]
	p3:10 -> frame:10 [color=green]
	p3:11 -> frame:11 [color=green]
	frame [label="<0>X|<1>X|<2>X|<3>X|<4>X|<5>X|<6>X|<7>X|<8>X|<9>X|<10>X|<11>X|<12>.|<13>.|<14>.|<15>.|<16>.|<17>.|<18>.|<19>.|<20>.|<21>.|<22>.|<23>.|<24>.|<25>.|<26>.|<27>.|<28>.|<29>.|<30>.|<31>.|"]
	subgraph right_ones {
		p3 [label="<0>0|<1>1|<8>8|<9>9|<10>10|<11>11|"]
		rank=sink
	}
	subgraph left_ones {
		p2 [label="<2>2|<3>3|<4>4|<5>5|<6>6|<7>7|"]
		rank=source
	}
}

How do I add a title over the whole thing? And how do I add a title at the top of each of the three boxes? I’m having trouble getting decent layout.

best references:

My standard answer would be to add titles/labels by inserting each node into a cluster. But clusters don’t always play well with rank specification, so we will look at “plan B” and “plan C”:

(Plan B) Some small changes that will add title/labels, though not exactly where you requested:

// Memsim
digraph {
	graph [rankdir=RL ranksep=1.5 label="My Happy Graph\n " labelloc=t]
	node [fontsize=8 height=0.2 margin="0.02 0.02" shape=record width=0.4]
	edge [arrowsize=0.4]
	p2:2 -> frame:2 [color=blue]
	p2:3 -> frame:3 [color=blue]
	p2:4 -> frame:4 [color=blue]
	p2:5 -> frame:5 [color=blue]
	p2:6 -> frame:6 [color=blue]
	p2:7 -> frame:7 [color=blue]
	p3:0 -> frame:0 [color=green]
	p3:1 -> frame:1 [color=green]
	p3:8 -> frame:8 [color=green]
	p3:9 -> frame:9 [color=green]
	p3:10 -> frame:10 [color=green]
	p3:11 -> frame:11 [color=green]
	frame [label="<0>X|<1>X|<2>X|<3>X|<4>X|<5>X|<6>X|<7>X|<8>X|<9>X|<10>X|<11>X|<12>.|<13>.|<14>.|<15>.|<16>.|<17>.|<18>.|<19>.|<20>.|<21>.|<22>.|<23>.|<24>.|<25>.|<26>.|<27>.|<28>.|<29>.|<30>.|<31>.|" xlabel="Big Top"]
	subgraph right_ones {
		p3 [label="<0>0|<1>1|<8>8|<9>9|<10>10|<11>11|" xlabel="chunk #1"]
		rank=sink
	}
	subgraph left_ones {
		p2 [label="<2>2|<3>3|<4>4|<5>5|<6>6|<7>7|" xlabel="Blob #99"]
		rank=source
	}
}

Giving:

And “Plan C” A complete reworking of your graph using “html” node labels to produce the desired result:

// Memsim
digraph {
	graph [rankdir=RL ranksep=1.5]
	// note shape=none, not record
	node [fontsize=8 height=0.2 margin="0.02 0.02" shape=none width=0.4]
	edge [arrowsize=0.4]
	p2:2 -> frame:2 [color=blue]
	p2:3 -> frame:3 [color=blue]
	p2:4 -> frame:4 [color=blue]
	p2:5 -> frame:5 [color=blue]
	p2:6 -> frame:6 [color=blue]
	p2:7 -> frame:7 [color=blue]
	p3:0 -> frame:0 [color=green]
	p3:1 -> frame:1 [color=green]
	p3:8 -> frame:8 [color=green]
	p3:9 -> frame:9 [color=green]
	p3:10 -> frame:10 [color=green]
	p3:11 -> frame:11 [color=green]
	// totally redid labels to html-like
	frame [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
     <TR><TD sides="b"><B><font color="red">Biggie</font></B></TD></TR>
     <TR><TD PORT="0">X</TD></TR>
     <TR><TD PORT="1">X</TD></TR>
     <TR><TD PORT="2">X</TD></TR>
     <TR><TD PORT="3">X</TD></TR>
     <TR><TD PORT="4">X</TD></TR>
     <TR><TD PORT="5">X</TD></TR>
     <TR><TD PORT="6">X</TD></TR>
     <TR><TD PORT="7">X</TD></TR>
     <TR><TD PORT="8">X</TD></TR>
     <TR><TD PORT="9">X</TD></TR>
     <TR><TD PORT="10">X</TD></TR>
     <TR><TD PORT="11">X</TD></TR>
     <TR><TD PORT="12">.</TD></TR>
     <TR><TD PORT="13">.</TD></TR>
     <TR><TD PORT="14">.</TD></TR>
     <TR><TD PORT="15">.</TD></TR>
     <TR><TD PORT="16">.</TD></TR>
     <TR><TD PORT="17">.</TD></TR>
     <TR><TD PORT="18">.</TD></TR>
     <TR><TD PORT="19">.</TD></TR>
     <TR><TD PORT="20">.</TD></TR>
     <TR><TD PORT="21">.</TD></TR>
     <TR><TD PORT="22">.</TD></TR>
     <TR><TD PORT="23">.</TD></TR>
     <TR><TD PORT="24">.</TD></TR>
     <TR><TD PORT="25">.</TD></TR>
     <TR><TD PORT="26">.</TD></TR>
     <TR><TD PORT="27">.</TD></TR>
     <TR><TD PORT="28">.</TD></TR>
     <TR><TD PORT="29">.</TD></TR>
     <TR><TD PORT="30">.</TD></TR>
     <TR><TD PORT="31">.</TD></TR>
  </TABLE>>];
	subgraph right_ones {
	p3 [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
     <TR><TD sides="b"><B><font color="purple">Chunk 89</font></B></TD></TR>
     <TR><TD PORT="0">0</TD></TR>
     <TR><TD PORT="1">1</TD></TR>
     <TR><TD PORT="8">8</TD></TR>
     <TR><TD PORT="9">9</TD></TR>
     <TR><TD PORT="10">10</TD></TR>
     <TR><TD PORT="11">11</TD></TR>
  </TABLE>>];
		rank=sink
	}
	subgraph left_ones {
	p2 [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
     <TR><TD sides="b"><B><font color="blue">Block #7</font></B></TD></TR>
     <TR><TD PORT="2">2</TD></TR>
     <TR><TD PORT="3">3</TD></TR>
     <TR><TD PORT="4">4</TD></TR>
     <TR><TD PORT="5">5</TD></TR>
     <TR><TD PORT="6">6</TD></TR>
     <TR><TD PORT="7">7</TD></TR>
  </TABLE>>];
		rank=source
	}
}

Thanks. And clusters are the only way to get the little boxes on the left and the right like you taught me? (I assume playing with one of the many other layout algorithms won’t solve it.)

What if instead of left and right, I had them all to the right but in multiple columns. Is that still the same problem? So e.g. col1: big box, col 2: small box 1, 2 and 3, col 3: small box 4,5,6?

Also what if I used the first sub-box (the top one) to be the label, and color it differently… or even suppress the lines? Is that possible?

I was not clear about clusters. Clusters are a way to collect multiple nodes into a “visual” subgraph (as opposed to a “logical” subgraph inside { subgraph components here }. Neither of us has displayed a cluster yet. The main thing that using clusters would help you with are titles/labels. But clusters often make positioning even more difficult, but I have a “good” version done with clusters. (see below)

Keeping all the small nodes (the pointer blocks) on the right. I tried using minlen (minlen | Graphviz) to move one node further away, but again not a good result:

Other layout engines - I too hoped that there might be happiness lurking in one of the other layout engines, but could find no joy there. Instead I got lots of odd layouts that made no obvious sense. My guess is that the dimensions of the nodes caused these layouts. Rats.

Here is a “good” cluster result, but note I had to swap tail & head on all the edges on the left side:

// Memsim
digraph {
	graph [rankdir=LR ranksep=1.5  label="my colorful network" ]
	graph [ peripheries=0]
	node [fontsize=8 height=0.2 margin="0.02 0.02" shape=record width=0.4]
	edge [arrowsize=0.4]

	subgraph cluster_right_ones{
	  graph [label="Right"]
		p3 [label="<0>0|<1>1|<8>8|<9>9|<10>10|<11>11|"]
	}
	subgraph cluster_left_ones {
	  graph[label=Left]
		p2 [label="<2>2|<3>3|<4>4|<5>5|<6>6|<7>7|"]
	}
	
	subgraph cluster1{
	graph [label="big"]
	// edges were placed AFTER all nodes & clusters were defined
	frame [label="<0>X|<1>X|<2>X|<3>X|<4>X|<5>X|<6>X|<7>X|<8>X|<9>X|<10>X|<11>X|<12>.|<13>.|<14>.|<15>.|<16>.|<17>.|<18>.|<19>.|<20>.|<21>.|<22>.|<23>.|<24>.|<25>.|<26>.|<27>.|<28>.|<29>.|<30>.|<31>.|"]
	}

	{edge [dir=back]
	frame:2 -> p2:2 [color=blue]
	frame:3 -> p2:3 [color=blue]
	frame:4 -> p2:4 [color=blue]
	frame:5 -> p2:5 [color=blue]
	frame:6 -> p2:6 [color=blue]
	frame:7 -> p2:7 [color=blue]
	}

	p3:0 -> frame:0 [color=green]
	p3:1 -> frame:1 [color=green]
	p3:8 -> frame:8 [color=green]
	p3:9 -> frame:9 [color=green]
	p3:10 -> frame:10 [color=green]
	p3:11 -> frame:11 [color=green]

}

Giving:

There seems to be no way to add color to individual cells of record nodes if you are using ports. Sorry.
Either use HTML nodes or cluster subgraphs.

I wrote a little API to encapsulate what you’ve taught me. diag.py is the module and diagmain.py is an example. Any improvements are welcome. In particular I can’t find a way to tell it to put each “tier” (subgraph) in a position, i.e. rank as a. number.