use graphviz can I make 2 blocks boundary. touch each others

63 views Asked by At

I done the following : enter image description here

using the following code : digraph G{


    graph [
         rankdir=LR
         ranksep = 0
         nodesep=0
         ]; 

        
      node [shape=box, margin="0,0"] 
      ;                                
      subgraph cluster_0 { 
         label= "pd_b2bc_cntl" 

         margin = "0"
       
          subgraph cluster_1 {
              rank=same
          label= "b2b_domain" 
          color = "green"
          1 [label="P"] 
          } 
         
         
         subgraph cluster_2 {
          label= "" 
         rank=same
          2 [label="\<", color=red]
         }
        subgraph cluster_3 {
          label= "" 
         rank=same
          3 [label="\>" color=blue] 
        }
        
          edge [style=invis]
          2 -> 1 [lhead=cluster_2];
          1 -> 3 [lhead=cluster_3];
          
      } 

}

I would like to get the < (red) and >(blue) at the boundary of the green block so they will touch each other the < should be at the right of the green block and the > should be at his left. can I do that with graphivz ? please help :) I am stuck .

I tried using rank but it is not working also tried using pos and its not working.

1

There are 1 answers

3
sroush On

This pushes the dot features.

  • remove rankdir so nodesep works as desired (undocumented)
  • input sequence of the clusters is critical (also undocumented)
  • use newrank to allow rank=same across clusters (this is documented)
digraph G{
  graph [
    ranksep = 0
    nodesep=0
    newrank=true  // allows rank=same
  ];

  node [shape=box, margin="0,0"]

  subgraph cluster_0 {
    label= "pd_b2bc_cntl"
    margin = "0"

    // sequence of the next three clusters is importantant to the result
    // rearranged to produce red->green->blue
    subgraph cluster_3 {
      label= ""
      3 [label="\>" color=blue]
    }
    subgraph cluster_1 {
      label= "b2b_domain"
      color = "green"
      1 [label="P"]
    }
    subgraph cluster_2 {
      label= ""
      2 [label="\<", color=red]
    }
    {
      rank=same
      edge[style=invis]
      2 -> 1 -> 3
    }
  }
}

Giving:
enter image description here