top-down subgraphs, left-right inside subgraphs

前端 未结 4 958
滥情空心
滥情空心 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:38

    rankdir doesn't work directly in the subgraph, but if you add another set of curly braces - whatever that's called - rankdir works. See below. Then, obviously you need more tricks to restore the alignment and ordering you're after.

    digraph G {
        node [shape = circle]
        0 [style = invis]
    
        0 -> "0A"
    
        subgraph clusterA {
            label=A
            {
                rank=same
                "0A"
                "1A"
                "2A" -> "0A" [label=•]
            }
        }
    
        subgraph clusterB {
            label=B
            {
                rank=same
                "0B"
                "1B"
                "2B" -> "0B" [label=•]
            }
        }
    
        subgraph clusterC {
            label=C
            {
                rank=same
                "0C"
                "1C"
                "2C" -> "0C" [label=•]
            }
        }
    
        subgraph clusterD {
            label=D
            {
                rank=same
                "0D"
                "1D"
                "2D" -> "0D" [label=•]
            }
        }
    
        subgraph clusterE {
            label=E
            {
                rank=same
                "0E"
                "1E"
                "2E" -> "0E" [label=•]
            }
        }
    
        subgraph clusterF {
            label=F
            {
                rank=same
                {node [shape = doublecircle] "0F" "1F"}
                "2F" -> "0F" [label=•]
            }
        }
    
        "0A" -> "1B" [label=a]
        "1A" -> "2B" [label=a]
        "0B" -> "1C" [label=b]
        "1B" -> "2C" [label=b]
        "0C" -> "1D" [label=c]
        "1C" -> "2D" [label=c]
        "0D" -> "1E" [label=d]
        "1D" -> "2E" [label=d]
        "0E" -> "1F" [label=e]
        "1E" -> "2F" [label=e]
    }
    

提交回复
热议问题