How to layout multiple subgraphs inside a master graph in dot?
Asked Answered
J

1

12

I am trying to create a graph using dot. The graph I have come up till now is given below and code is also given.

enter image description here

Code

digraph top {
  node [shape=record ,penwidth = 2,fontsize=25];
  graph [labeljust=l]
  ratio="fill";

  subgraph cluster_1 {
    label = "Box 1";
    fontsize=40;
    subgraph cluster_2 {
      label = "Box 2";
      fontsize=38

      subgraph cluster_3 {
        label = "Box 3";
        fontsize=36;
        
        subgraph cluster_4 {
            label = "Box 4";
            fontsize=34;
            
            
            
            subgraph cluster_7 {
                    label = "Box 5";
                    fontsize=30;
                    color=blue;
                    style="dashed";
                    subgraph cluster8 {
                        color=red;
                        label = "Box 6";
                        subgraph cluster9 {
                            label = "Box 7";
                            subgraph cluster10 {
                                label = "Box 8";
                                l4 [label = "{  Label : X \l| \
                                             Label : 2014-12-05 \l| \
                                             Label : 2015-01-04 \l| \
                                             Label : true \l} \
                                            "];
                            }
                            subgraph cluster11 {
                                label = "Box 9";
                                l5 [label = "{  Label : X \l| \
                                             Label : 2015-03-06 \l| \
                                             Label : 2015-01-04 \l| \
                                             Label : true \l} \
                                            "];
                            }
                            subgraph cluster12 {
                                label = "Box 10";
                                l6 [label = "{  Label : X \l| \
                                             Label : 2015-07-03 \l| \
                                             Label : 2015-08-31 \l| \
                                             Label : true \l} \
                                            "];
                            }
                            
                        }
                        
                    }
                    subgraph cluster13 {
                        color=green;
                        label = "Box 11";
                        subgraph cluster {
                            label = "Box 12";
                            "Label : 2 days"
                        }
                    }
                    subgraph cluster14 {
                        label = "Box 13";
                        style=bold;
                        fontsize=20;
                        color=grey;
                        subgraph cluster15 {
                            label = "Box 14";
                            subgraph cluster16 {
                                label = "Box 15";
                                subgraph cluster17 {
                                    label = "if";
                                    subgraph cluster18 {
                                        label = "and";
                                        subgraph cluster19 {
                                            label = "Box 16";
                                            subgraph cluster20 {
                                                label = "Box 17";
                                                l7 [label = "{  Label : A \l| \
                                                                 Label : B \l| \
                                                                 Label : C \l| \
                                                                 Label : D \l} \
                                                                "];
                                            }
                                        }
                                        subgraph cluster21 {
                                            label = "Box 18";
                                            subgraph cluster {
                                                label = "Box 19";
                                                "Label : T"
                                            }
                                        }
                                    }
                                }
                                subgraph cluster29 {
                                    label = "then";
                                    "Label : O"
                                }
                            }
                        }
                        subgraph cluster22 {
                            label = "Box 19";
                            subgraph cluster30 {
                                label = "Box 20";
                                subgraph cluster31 {
                                    label = "if";
                                    subgraph cluster32 {
                                        label = "and";
                                        subgraph cluster33 {
                                            label = "Box 21";
                                            subgraph cluster34 {
                                                label = "Box 22";
                                                l8 [label = "{  Label : A \l| \
                                                                 Label : B \l| \
                                                                 Label : C \l| \
                                                                 Label : D \l} \
                                                                "];
                                            }
                                        }
                                        subgraph cluster35 {
                                            label = "Box 23";
                                            subgraph cluster {
                                                label = "Box 24";
                                                "Label : T"
                                            }
                                        }
                                    }
                                }
                                subgraph cluster36 {
                                    label = "then";
                                    "Label : C"
                                }
                            }
                        }

                    }
            }
            
            subgraph cluster_5 {
                label = "Box 24"
                fontsize=30;
                
                color=red;
                
                subgraph cluster_6 {
                    label = "Box 25";
                    
                    subgraph cluster_8 {
                        label = "Box 26";
                        
                        subgraph cluster {
                            label = "Box  27";
                            "Label : 200"
                        }
                    
                    }
                
                }
                subgraph cluster {
                    label = "Box 28";
                    subgraph cluster {
                        label = "Box 29";
                        l1 [label = "{  Label : F \l| \
                                        Label : N \l |\
                                        Label : H \l |\
                                        Label : N \l} \
                                        "];
                        
                        subgraph cluster {
                            label = "Box 30";
                            subgraph cluster {
                                label = "Box 31";
                                l2 [label = "{  C \l| \
                                                I\l} \
                                                "];
                            }
                            l3 [label = "{  label : F \l| \
                                             label : F \l| \
                                             label : A \l| \
                                             label : F \l} \
                                            "];
                        }
                    }
                
                }
                
            }
            
        }
      }
    }
  }
}

The problem I am facing is about the layout of the subgraphs. I am interested in arranging the Boxes "Box 13", "Box 11" and "Box 6" in vertical mannner. I was interested in putting the "Box 6" and "Box 11" in first row and "Box 13" in the second row. This arrangement will be inside the "Box 5". I am aware of the layout options available here . And I can put the three Boxes (6,11,13) into individual files and combine. But I am not clear about how to layout the three boxes inside the "Box 5".

Jijib answered 22/4, 2015 at 7:58 Comment(4)
I am creating this graph based on XML and need to create more graphs of similar nature for different XML. Suggestion about a better suited tool is also welcome.Jijib
Going through the documentation it looks likes gvpr might help in combining the smaller graphs into a master. But I am yet to understand its inner working.Jijib
Did you ever tried XML-Spy from altova or JDeveloper from Oracle? They have support for XSD, which looks a little bit similar like your output.Pronate
You should try table layouts, there you have all the HTML features including rowspan and colspan, see Table and Cell Gradients | Graphviz for more.Polymerize
P
0

You need some scaffolding i.e. invisible edges (and maybe nodes), try add e.g. the following before last curly bracket:

"Label : C"->"Label : 2 days"->l6[color=none]
Polycotyledon answered 11/4, 2019 at 18:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.