Dot more layout control

  1. Attribute declarations are not additive, they replace earlier definitions. You want style=“rounded,dashed”

  2. To try to keep nodes in the sequence you want, use something like this (invisible edges):
    { rank = same; C3R1 -> C3R2 -> C3R3 -> C3R4 [style=invis] };

  3. The underlying problem with the last rank (column) is a bug in dot related to rankdir=LR (setting rankdir causes odd node ordering (#1953) · Issues · graphviz / graphviz · GitLab)
    Here is your graph tweaked. Correct w/ std rankdir, funky result w/ rankdir=LR:

     digraph G {
     //	rankdir="LR";
     	boxme [shape="box"]
    
     	start -> C1R1 ;
     	start -> C1R2 ;
     	C1R1 -> boxme ;
     	C1R1 -> C2R1 ;
     	boxme -> C2R2 ;
     	boxme -> C2R3 ;
     	subgraph cluster_0 {
     		graph [label= "surrounded"; color=blue; style="rounded,dashed" ] 
     		node [ style=filled, color=green ];
     		{ rank = same;  C3R1 -> C3R2 -> C3R3 -> C3R4  [style=invis]} 
     	}
     	C2R1 -> C3R1 ;
     	C2R1 -> C3R2 ;
     	C2R2 -> C3R3 ;
     	C2R2 -> C3R4 ;
     	C2R3 -> C3R5 ;
     	C2R3 -> C3R6 ;
     	{ rank = same; C1R1 -> C1R2   [style=invis] }
     	{ rank = same; C2R1 -> C2R2 -> C2R3  [style=invis]  }
     	{ rank = same; C3R5 -> C3R6  [style=invis] }
     }
    


1 Like