cluster-computinggraphvizrankingdotsubgraph

Graphviz - how do I change rankdir in a subgraph within a subgraph?


I've got the following graph. I'm content with it, except for the nodes within the red rectangle:

(Here's the Graphviz Visual Editor Link)

I'd rather have the nodes "hollow" and "hohl" be atop each other, like so: (Here's the Graphviz Visual Editor Link])

Every attempt at adding a nested subgraph was unsuccessful, despite using

Can anyone offer any advice?

Bonus question: I'd also prefer the "rabbit hole" node to be horizontically centered, but I haven't found out how to do that either.


Solution

  • p.s. rankdir applies to the entire (root) graph

    digraph {
      fontname="Helvetica,Arial,sans-serif"
      fontsize=18
      rankdir="TB"
      
      node [fontname="Helvetica,Arial,sans-serif"]
      edge [fontname="Helvetica,Arial,sans-serif"]
      layout=dot
      
      rabbithole [group=R label=<<FONT POINT-SIZE="30">"rabbit hole"</FONT>> shape=rectangle]
      rabbit     [label="\"rabbit\"\n(origin unknown)"]
      rabbithole -> rabbit
      rabbithole -> hole
      
      {rank=sink  // keep on same rank
        hulahoop [label="\"Hula Hoop\""]
        holy     [label="\"holy\""]
        hell     [label="\"hell\""]
      }
      
      hulaz -> hulahoop [minlen=2 dir=none label="unrelated"]  // push to bottom
      hulaz -> holy [dir=none label="unrelated"]
      hulaz -> hell [dir=none label="unrelated"]
       
      subgraph cluster_hulaz{
        hole [group=R label="\"hole\""]
      
        hulaz  [group=R label=<<I><FONT POINT-SIZE="20">"hulaz"</FONT></I><BR/>(PGmc root,<BR/>"hollow")>, shape=doublecircle]
        hollow [group=2 label="\"hollow\""]
        hohl   [group=2 label="\"hohl\"\n(de, \"hollow\")"]
        Höhle  [label="\"Höhle\"\n(de, \"cave\")"]
      
          { rank=same
          hole hollow
          }
          { rank=same
          hulaz  hohl Höhle
          }
          hole -> hulaz [dir=none]
          hulaz -> hollow [dir=none]
          hulaz -> hohl [dir=none]
          hollow -> hohl [dir=none]
          hohl -> Höhle [dir=none]
      }
    }
    

    Giving:
    enter image description here