top-down subgraphs, left-right inside subgraphs

前端 未结 4 1035
滥情空心
滥情空心 2021-01-31 03:14

I\'d like to have my graph looks like this:

But I can only get this:

4条回答
  •  情书的邮戳
    2021-01-31 03:24

    An update on @marapet's answer using group

    digraph g {
    rankdir="LR";
    node[shape = circle, fontsize=14];
    fontsize=18;
    labeljust="l";
    
    edge[style=invis, fontsize=12];
    
    { rank=same;
        0 [group=a style = invis];
        01 [style = invis];
        02 [group=b style=invis];
        0 -> 01 -> 02;
    }
    
    subgraph clusterA {
        "0A" [group=a]
        "0A" -> "1A" -> "2A";
        "2A" -> "0A" [label=".", constraint=false, style=solid];
        label="A";
    }
    
    subgraph clusterB {
        "0B" -> "1B" -> "2B";
        "2B" -> "0B" [label=".", constraint=false, style=solid];
        label="B";
    }
    
    subgraph clusterC {
        "0C" [group=b]
        "1C" [group=b]
        "0C" -> "1C" -> "2C";
        "2C" -> "0C" [label=".", constraint=false, style=solid];
        label="C";
    }
    
    0 -> "0A"[style=solid];
    01 -> "0B"[style=invis];
    02 -> "0C"[style=invis];
    
    // edges between clusters
    edge[constraint=false, style=solid];
    "0A" -> "1B" [label=a]
    "1A" -> "2B" [label=a]
    "0B" -> "1C" [label=b]
    "1B" -> "2C" [label=b]
    }
    

提交回复
热议问题