子图不';t出现在graphviz图表中

子图不';t出现在graphviz图表中,graph,charts,graphviz,Graph,Charts,Graphviz,我不明白为什么子图在这里不起作用: digraph virtPfr { node [ shape=box ] Start [ style=rounded, label="create folder profiles" ] subgraph asd { label = "copy files from other profiles" cpIfDestFilesExist [

我不明白为什么子图在这里不起作用:

digraph virtPfr {
    node [
        shape=box
    ]

    Start [
        style=rounded,
        label="create folder profiles"
    ]

    subgraph asd {
        label = "copy files from other profiles"

        cpIfDestFilesExist [
            label = "Check for file existance"
        ]

        Cp [
            label = "Copy"
        ]
    }

    Start -> asd

    cpIfDestFilesExist -> Start
    cpIfDestFilesExist -> Cp
}
但这个代码是有效的:

digraph G {

    node [
        shape = "record"
    ]

    Animal [
        label = "Animal name and age"
    ]

    subgraph clusterAnimalImpl {
        label = "Package animal.tmpl"

        Dog [
            label = "Dog name and age"
        ]

        Cat [
            label = "Cat name and age"
        ]
    }

    Dog -> Animal
    Cat -> Animal
    Dog -> Cat
}
我不明白,与底部图形相比,顶部图形有什么不同,底部可以工作,但顶部不能。我已经把眼睛挖出来了。我看不出这里有什么问题

请帮助解决以下几个问题:

  • 子图名称必须以关键字
    cluster
    开头
  • 不能将边直接连接到子图,而是可以使用所述的
    lhead
    /
    ltail
    解决方法
对于您的图形,它可能如下所示:

digraph virtPfr {
    graph [compound=true]
    node [
        shape=box
    ]

    Start [
        style=rounded,
        label="create folder profiles"
    ]

    subgraph cluster_asd {
        label = "copy files from other profiles"

        cpIfDestFilesExist [
            label = "Check for file existance"
        ]

        Cp [
            label = "Copy"
        ]
    }

    Start -> cpIfDestFilesExist [lhead=cluster_asd]

    cpIfDestFilesExist -> Start
    cpIfDestFilesExist -> Cp
}
这将生成以下输出: