0

I have to create process diagramms multiple times a week. I looked into graphviz to make the process less cumbersome. I just started out learning it and it is truly great. However, I cannot figure out how to use subplots to create the layout I want.

  • I want one "lane"/"row" with the process diagram
  • I want one "lane"/"row" with notes that show, how the step is annoying at the moment
  • I want one "lane"/"row" with general information about the process

I tried fiddling around with subgraphs, but that did not work. Is there some way I can achieve this? Here is the code for an example. I also added a picture to illustrate what I want to achieve: My goal. A reusabile layout like this

digraph{
graph[rankdir =LR]

// the steps
subgraph steps{
node[shape = box]
S_1[label="Step 1"];
S_2[label = "Step 2"];
S_3[label = "Step ..."];
S_4[label = "Step k"]


S_1 -> S_2 -> S_3 -> S_4;
}

// the problems
subgraph problem {
node[shape = box, color = "red",fontsize = 8]
S_1p[label= "This is not working\nat all. People simply skip this\nstep."]
S_3p[label  = "Instead of changing\nthe session setting,\nusers simply call colleagues via phone"]

S_1p->S_1 //argh
S_3p -> S_3 //argh
}



//the notes
subgraph notes{
 node[shape = plaintext, color = "black",fontsize = 8]

 S_1n[label="This is really important additional information"]
 S_3n[label="This one as well"]

 S_1n -> S_1;
 S_3n -> S_3;
}

}

user105833
  • 39
  • 3
  • Maybe you should look into: `{ rank=same; S_1; S_2; S_3; S_4;}` and not setting the `tankdir` in the graph. – albert Oct 11 '21 at 17:54

1 Answers1

1
  • subgraphs and cluster subgraphs are easily confused. see section 3.2 of https://www.graphviz.org/pdf/dotguide.pdf
  • there is no direct way to order or size clusters, you need invisible nodes and edges. a pain
  • this result is ~ close, but the purple edges are sub-optimal! (to my eye). Dot works hard NOT to draw edges on top of nodes or other structures. sorry.
 // graph[rankdir =LR]  << use default TB 
 graph [newrank=true]  // dang, does not help the curvy edges
 // the steps
 subgraph cluster_steps{
 {
  rank=same // keep horizontal
  node[shape = box]
  S_1[label="Step 1"];
  S_2[label = "Step 2"];
  S_3[label = "Step ..."];
  S_4[label = "Step k"]

  invisA[shape=point style=invis group=I]
  invisA -> S_1 [style=invis]
  //edge [constraint=false]
  S_1 -> S_2 -> S_3 -> S_4;
  }
 }

 // the problems
 subgraph cluster_problem {
 {
  rank=same // keep horizontal
  node[shape = box, color = "red",fontsize = 8]
  S_1p[label= "This is not working\nat all. People simply skip this\nstep."]
  S_3p[label  = "Instead of changing\nthe session setting,\nusers simply call colleagues via phone"]

  invisB[shape=point style=invis group=I]
  invisB-> S_1p  [style=invis]

  edge [constraint=false color=red]
  S_1p->S_1   //argh  << pirate talk??
  S_3p -> S_3 //argh
  }
}
 //the notes
 subgraph cluster_notes{
 {
  rank=same // keep horizontal
  node[shape = plaintext, color = "black",fontsize = 8]

  S_1n[label="This is really important additional information"]
  S_3n[label="This one as well"]

  invisC[shape=point style=invis group=I]
  invisC-> S_1n [style=invis]

  edge [constraint=false color=purple]  
  S_1n -> S_1;
  S_3n -> S_3;
  }
 }
 edge[style=invis]
 invisA ->  invisB ->  invisC
 }

Giving:
enter image description here

sroush
  • 5,375
  • 2
  • 5
  • 11
  • This is great! I think I can get away with the edge-through-node problem by moving the "hint" box (last one) up top by changing the last line to invisC -> invisA -> invisB. (The //argh comments were simply cries of despair with a pirate-y touch) – user105833 Oct 12 '21 at 07:40
  • Depending on the user requirements maybe `splines=false;` can be used (see also https://stackoverflow.com/a/4674568/1657886) – albert Oct 12 '21 at 10:17