Layout question

Please look at the attached files. I tried many different options and layout algorithm, kind of trial and error and couldn’t find how to solve it. I don’t want the arrows crisscrossing so much. Two option that I see just by looking is that one little box is moved further to the right so that the two little boxes are in different “tiers”. Note that this is a small example of a far more elaborate graph which follows the same analogy. (It’s a page table to physical memory illustration)

Digraph.gv (590 Bytes)
Digraph.gv.pdf (13.8 KB)

Here is a handdrawn idea of what I would like, as the diagram becomes more complex. I think coloring the lines would help legibility in a significant way as well ([thanks Steve Rousch]

(Layout question (#2467) · Issues · graphviz / graphviz · GitLab)


You can stagger the nodes on the left by setting the minlen attribute of edges minlen | Graphviz. But the edges start looking ugly (see below).

I like placing the small nodes on both sides, like so:

digraph {
	graph [rankdir=RL]
	graph [overlap=scalexy]  // dot ignores overlap attribute
	graph [ranksep="1.5"]    // spread things out
	node [shape=record]
	edge [color=red]         // color edges
	p2:2 -> frame:2
	p2:3 -> frame:3
	p2:4 -> frame:4
	p2:5 -> frame:5
	p2:6 -> frame:6
	p2:7 -> frame:7
	{ rank=source  // pick a side
	p2 [label="<2>2|<3>3|<4>4|<5>5|<6>6|<7>7|"]
	edge [color=green]       // color edges
	p3:0 -> frame:0
	p3:1 -> frame:1
	p3:8 -> frame:8
	p3:9 -> frame:9
	p3:10 -> frame:10
	p3:11 -> frame:11
	{ rank=sink  // pick a side
	p3 [label="<0>0|<1>1|<8>8|<9>9|<10>10|<11>11|"]
	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>.|"]


Here are the ugly staggered edges:

Thanks! I am implementing this in my app. I am generating the ,dot file programmatically. This one seems to crash for a reason I can’t tell:

// Memsim
digraph {
graph [rankdir=RL]
graph [ranksep=1.5]
node [shape=record]
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>X|<13>X|<14>X|<15>X|<16>X|<17>X|<18>X|<19>X|<20>X|<21>X|<22>X|<23>X|<24>X|<25>X|<26>X|<27>X|<28>X|<29>X|<30>X|<31>X|<32>X|<33>X|<34>X|<35>X|<36>X|<37>X|<38>X|<39>X|<40>X|<41>X|<42>X|<43>X|<44>X|<45>X|<46>X|<47>X|<48>X|<49>X|<50>X|<51>X|<52>X|<53>X|<54>X|<55>X|<56>X|<57>X|<58>X|<59>X|<60>X|<61>X|<62>X|<63>X|<64>X|<65>X|<66>X|<67>X|<68>X|<69>X|<70>X|<71>X|<72>.|<73>.|<74>.|<75>.|<76>X|<77>X|<78>X|<79>X|<80>X|<81>X|<82>.|<83>.|<84>.|<85>.|<86>.|<87>.|<88>.|<89>.|<90>.|<91>.|<92>.|<93>.|<94>.|<95>.|<96>.|<97>.|<98>.|<99>.|<100>.|<101>.|<102>.|<103>.|<104>.|<105>.|<106>.|<107>.|<108>.|<109>.|<110>.|<111>.|<112>.|<113>.|<114>.|<115>.|<116>.|<117>.|<118>.|<119>.|<120>.|<121>.|<122>.|<123>.|<124>.|<125>.|<126>.|<127>.|”]
subgraph right_ones {
p5:44 → frame:44 [color=orange]
p5:45 → frame:45 [color=orange]
p5:46 → frame:46 [color=orange]
p5:47 → frame:47 [color=orange]
p5:48 → frame:48 [color=orange]
p5:49 → frame:49 [color=orange]
p5:50 → frame:50 [color=orange]
p5:51 → frame:51 [color=orange]
p5:52 → frame:52 [color=orange]
p5:53 → frame:53 [color=orange]
p5:54 → frame:54 [color=orange]
p5:55 → frame:55 [color=orange]
p5 [label=“<44>44|<45>45|<46>46|<47>47|<48>48|<49>49|<50>50|<51>51|<52>52|<53>53|<54>54|<55>55|”]
p7:62 → frame:62 [color=orange]
p7:63 → frame:63 [color=orange]
p7:64 → frame:64 [color=orange]
p7:65 → frame:65 [color=orange]
p7:66 → frame:66 [color=orange]
p7:67 → frame:67 [color=orange]
p7:68 → frame:68 [color=orange]
p7:69 → frame:69 [color=orange]
p7:70 → frame:70 [color=orange]
p7:71 → frame:71 [color=orange]
p7 [label=“<62>62|<63>63|<64>64|<65>65|<66>66|<67>67|<68>68|<69>69|<70>70|<71>71|”]
p6:56 → frame:56 [color=orange]
p6:57 → frame:57 [color=orange]
p6:58 → frame:58 [color=orange]
p6:59 → frame:59 [color=orange]
p6:60 → frame:60 [color=orange]
p6:61 → frame:61 [color=orange]
p6 [label=“<56>56|<57>57|<58>58|<59>59|<60>60|<61>61|”]
p10:76 → frame:76 [color=purple]
p10:77 → frame:77 [color=purple]
p10:78 → frame:78 [color=purple]
p10:79 → frame:79 [color=purple]
p10:80 → frame:80 [color=purple]
p10:81 → frame:81 [color=purple]
p10 [label=“<76>76|<77>77|<78>78|<79>79|<80>80|<81>81|”]
subgraph left_ones {
p2:20 → frame:20 [color=blue]
p2:21 → frame:21 [color=blue]
p2:22 → frame:22 [color=blue]
p2:23 → frame:23 [color=blue]
p2:34 → frame:34 [color=blue]
p2:35 → frame:35 [color=blue]
p2 [label=“<20>20|<21>21|<22>22|<23>23|<34>34|<35>35|”]
p1:18 → frame:18 [color=blue]
p1:19 → frame:19 [color=blue]
p1 [label=“<18>18|<19>19|”]
p9:36 → frame:36 [color=red]
p9:37 → frame:37 [color=red]
p9:38 → frame:38 [color=red]
p9:39 → frame:39 [color=red]
p9:40 → frame:40 [color=red]
p9:41 → frame:41 [color=red]
p9:42 → frame:42 [color=red]
p9:43 → frame:43 [color=red]
p9 [label=“<36>36|<37>37|<38>38|<39>39|<40>40|<41>41|<42>42|<43>43|”]

I figured out how to get the crash not to happen – by trial and error. It seems the edges should not be inside the subgraph braces.