Search code examples
bordercluster-computinggraphvizranksubgraph

Missing border of graphviz cluster with rank


We're trying to replace an image of diagram to graphviz graph:

enter image description here

Current state is the following graph:

enter image description here

digraph pipeline {
    node [shape=record fontname=Helvetica fontsize=10 style=filled color="#4c7aa4" fillcolor="#5b9bd5" fontcolor="white"];
    edge [color="#62a8e7"];
    splines=ortho;
    capture [label="Capture\nDecode"];
    resize [label="Resize\nConvert"];
    detect [label="Detect faces"];
    show [label="Visualize\nDisplay"];
    temp_3 [style=invis shape=point width=0];
    subgraph cluster_tmp {
      graph[style=dashed];
      postproc_1 [label="Crop\nResize\nConvert"];
      postproc_2 [label="Crop\nResize\nConvert"];
      age_gender [label="Classify\nAge/gender"];
      emo [label="Classify\nEmotions"];
      temp_1 [style=invis shape=point width=0];
      temp_2 [style=invis shape=point width=0];
      { rank=same; temp_2 postproc_2 emo }
      label="(for each face)";
    }
    { rank=same; capture resize detect temp_1 postproc_1 age_gender temp_3 show }
    capture -> resize -> detect
    detect -> temp_1 [arrowhead=none]
    temp_1 -> postproc_1 -> age_gender
    temp_1 -> temp_2 [arrowhead=none]
    capture -> temp_2 [arrowhead=none]
    temp_2 -> postproc_2 -> emo
    capture -> postproc_1

    age_gender -> temp_3 [arrowhead=none]
    emo -> temp_3 [arrowhead=none]
    temp_3 -> show

    edge[style=invis];
    postproc_1 -> postproc_2
    age_gender -> emo
}

Is it possible to align nodes in the way that the subgraph in the middle will have a full border?


Solution

  • Fixed that:

    enter image description here

    digraph pipeline {
      node [shape=record fontname=Helvetica fontsize=10 style=filled color="#4c7aa4" fillcolor="#5b9bd5" fontcolor="white"];
      edge [color="#62a8e7"];
      splines=ortho;
    
      rankdir = LR;
      subgraph cluster_0 {
        color=invis;
        capture [label="Capture\nDecode"];
        resize [label="Resize\nConvert"];
        detect [label="Detect faces"];
        capture -> resize -> detect
      }
    
      subgraph cluster_1 {
        graph[style=dashed];
    
        subgraph cluster_2 {
          color=invis;
          temp_4 [style=invis shape=point width=0];
          postproc_1 [label="Crop\nResize\nConvert"];
          age_gender [label="Classify\nAge/gender"];
          postproc_1 -> age_gender [constraint=true]
          temp_4 -> postproc_1 [constraint=none]
        }
    
        subgraph cluster_3 {
          color=invis;
          postproc_2 [label="Crop\nResize\nConvert"];
          emo [label="Classify\nEmotions"];
          postproc_2 -> emo [constraint=true]
        }
        label="(for each face)";
      }
    
      temp_1 [style=invis shape=point width=0];
      temp_2 [style=invis shape=point width=0];
      detect -> temp_1 [arrowhead=none]
      temp_1 -> postproc_1
    
      capture -> {temp_4, temp_2} [arrowhead=none constraint=false]
      temp_2 -> postproc_2
    
      temp_1 -> temp_2 [arrowhead=none constraint=false]
    
      temp_3 [style=invis shape=point width=0];
      show [label="Visualize\nDisplay"];
    
      {age_gender, emo} -> temp_3 [arrowhead=none]
      temp_3 -> show
    }