Graphviz 连接嵌套子图

Graphviz connect nested subgraphs

问题

类似这个问题(GraphViz - How to connect subgraphs?)我想连接一些子图。只有这一次我需要连接嵌套子图...Graphviz 似乎对我的语法不满意。

来源

digraph G {
        compound=true

        subgraph cluster_family1 {
                graph [ label="Family1"; ]
                subgraph cluster_genus1 {
                        graph [ label="Genus1"; ]
                        species_1
                        species_2
                }
                subgraph cluster_genus2 {
                        graph [ label="Genus2"; ]
                        species_3
                        species_4
                }
        }
        subgraph cluster_family2 {
                graph [ label="Family2"; ]
                subgraph cluster_genus2 {
                        graph [ label="Genus3"; ]
                        species_5
                        species_6
                }
        }
        species_2 -> species_3 [ lhead=cluster_genus1 ] # TODO: Fix this line!!
}

生成的图表没有我希望的所需子图箭头指向。相反,我收到错误:

dot -Tsvg source.dot -o output.svg
Warning: Two clusters named cluster_genus2 - the second will be ignored
Warning: species_2 -> species_3: head not inside head cluster cluster_genus1

两个错误:

  • 重复的集群名称:(cluster_genus2)
  • 混淆你的优势

您可能需要其他调整,例如,如果您希望在 species_2[=12= 之前 species_1 ]

digraph G {
        compound=true

        subgraph cluster_family1 {
                graph [ label="Family1"; ]
                subgraph cluster_genus1 {
                        graph [ label="Genus1"; ]
                        species_1
                        species_2
                }
                subgraph cluster_genus2 {
                        graph [ label="Genus2"; ]
                        species_3
                        species_4
                }
        }
        subgraph cluster_family2 {
                graph [ label="Family2"; ]
                subgraph cluster_genus3 {  // fixed duplicate name
                        graph [ label="Genus3"; ]
                        species_5
                        species_6
                }
        }
        species_2 -> species_3 [ ltail=cluster_genus1 ] # changed head to tail??
}

给予: