rgraphvizdotdiagrammer

Force edges in graphviz to overlap each other


I am trying to create in DiagrammeR the flowchart below. Although I am using the concentrate=true attribute option it appears that the edges cannot forced to overlap each other and have common arrow head.

Desired output

enter image description here

I have tried the solution but the outcome is not what expected


DiagrammeR::grViz("
              digraph box  {
              
                    graph [label = '', 
                           labelloc='t';         
                           layout=dot, 
                           splines=ortho,
                           concentrate=true,
                           overlap = true, 
                           fontsize = 15]        
                    
                    node [shape=rect, 
                          fontname = Helvetica, 
                          color = '#0b41cd', 
                          style = filled,        
                          fillcolor = '#00a3e0', 
                          fontsize = 11,
                          fontcolor='#FFFFFF']         
                    
                            
                    rec1  [label = '@@1', width = 2, height = 0.5]; 
                    rec2  [label = '@@2', width = 2, height = 0.5]; 
                    rec3  [label = '@@3', width = 2, height = 0.5]; 
                    rec4  [label = '@@4', width = 2, height = 0.5]; 
                    rec5  [label = '@@5', width = 2, height = 0.5]; 
                    rec6  [label = '@@6', width=1];
                    rec7  [label = '@@7', width=1];
                    rec8  [label = '@@8', width=2];
                    rec9  [label = '@@9'];
                    rec10  [label = '@@10', width=2];

                    blank1 [label = '', color = '#000000', shape=point, width = 0, height = 0]
                    blank2 [label = '', color = '#000000', shape=point, width = 0, height = 0]
                    blank3 [label = '', color = '#000000', shape=point, width = 0, height = 0]
                    blank4 [label = '', color = '#000000', shape=point, width = 0, height = 0]
                    blank5 [label = '', color = '#000000', shape=point, width = 0, height = 0]
                 
                    rec1  -> blank3[dir='none']
                    blank3 -> blank4 -> blank5 [dir='none']
                    blank1 -> blank2 -> blank3 [dir='none']
  
                    subgraph {
                      rank = same; blank1; blank2; blank3; blank4; blank5;
                    }
              
                    blank1 -> rec2
                    blank2 -> rec3
                    blank4 -> rec4
                    blank5 -> rec5
              
              
                    subgraph {
                      rank = same; rec2; rec3; rec4; rec5;
                      rec2 -> rec3 -> rec4 -> rec5 [style=invis]
                    }
              
                    rec4 -> rec6
                    rec4 -> rec7
              
                    subgraph {
                      rank = same;  rec6; rec7; 
                      rec6 -> rec7 [style=invis]
                    }
              
              
                    rec2 -> rec10
                    rec3 -> rec8
                    rec6 -> rec10
                    rec7 -> rec8
                    rec8 -> rec9 
                    rec9 -> rec10 [style=invis]
              
              
                    subgraph {
                      rank = same; rec8; rec9; rec10;
                    }
              
                  }

                  [1]:  'A'
                  [2]:  'B'
                  [3]:  'C'
                  [4]:  'D'
                  [5]:  'E'
                  [6]:  'F'
                  [7]:  'G'
                  [8]:  'H'
                  [9]:  'I'
                  [10]: 'J'

 ")

enter image description here

Not sure why this is happening. Does anyone have any ideas?


Solution

  • I believe that concentrate is ignored when splines=ortho.
    Maybe DiagrammeR can create your graph more easily, but here is a plain dot solution.

    digraph box  {
                        graph [label = "", 
                               labelloc="t";         
                               layout=dot, 
                               splines=ortho,
                               concentrate=true,  //  not used here
                               //overlap = true,  // does not apply to dot
                               fontsize = 15
                   ranksep=.4]        
                        
                        node [shape=rect, 
                              fontname = Helvetica, 
                              color = "#0b41cd", 
                              style = filled,        
                              fillcolor = "#00a3e0", 
                              fontsize = 11,
                              fontcolor="#FFFFFF"]         
                        
                        rec1  [label = "1", width = 2, height = 0.5 group=a1]; 
                        rec2  [label = "2", width = 2, height = 0.5 group=a2]; 
                        rec3  [label = "3", width = 2, height = 0.5 group=a3]; 
                        rec4  [label = "4", width = 2, height = 0.5 group=a4]; 
                        rec5  [label = "5", width = 2, height = 0.5 group=a5]; 
                        rec6  [label = "6", width=1 group=b1];
                        rec7  [label = "7", width=1 group=b3];
                        rec8  [label = "8", width=2 group=a2];
                        rec9  [label = "9"   group=a3];
                        rec10  [label = "10", width=2  group=b3];
                
                      subgraph {
                          rank = same; rec2; rec3; rec4; rec5;
                          rec2 -> rec3 -> rec4 -> rec5 [style=invis]
                        }
    
                      subgraph {
                          rank = same;
                  node [label="", fillcolor="black",
                       shape=point, width=.01, height=.01]
                  blank1 [ group=a2];
                  blank2 [ group=a3];
                  blank3 [ group=a1];
                  blank4 [ group=a4];
                  blank5 [ group=a5];
                        }
                      subgraph {
                          rank = same;
                  node [label="", fillcolor="black",
                       shape=point, width=.01, height=.01]
                  blank11 [ group=b1];
                  blank12 [ group=a4];
                  blank13 [ group=b3];
                          blank11 -> blank12 -> blank13 [dir="none"]
                        }      
                       subgraph {
                          rank = same;
                  node [label = "", fillcolor="black",
                        shape=point, width=.01, height=.01]
                  blank21 [ group=a2];
                  blank22 [ group=a3];
                  blank23 [ group=b1];
                  blank24 [ group=b3];
                          blank21 -> blank22 -> blank23 -> blank24 [dir="none"]
                        }      
                        subgraph {
                          rank = same; rec8; rec9; rec10;
                        }
                        {
                edge [dir=none]
                        rec1  -> blank3 
                        blank3 -> blank4 -> blank5 
                        blank1 -> blank2 -> blank3 
                        rec2 -> blank21  [minlen=3]   //rec10
                        rec3 -> blank22  [minlen=3]  //rec8
                        rec6 -> blank23      //rec10
                        rec7 -> blank24      //rec8  [weight=0]
                    rec4  -> blank12
                }
    
                blank11-> rec6
                blank13-> rec7
     
                        blank1 -> rec2
                        blank2 -> rec3
                        blank4 -> rec4
                        blank5 -> rec5
                  
                        subgraph {
                          rank = same;  rec6; rec7; 
                          rec6 -> rec7 [style=invis]
                        }
                  
                        blank21 -> rec8
                        blank24 -> rec10
                        rec8 -> rec9 [weight=1]
                        rec9 -> rec10 [style=invis]
    }
    

    Giving:
    enter image description here