子图没有出现在 graphviz 图表中

Subgraph doesn't appear in graphviz chart

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

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开头。
  • 您不能将边直接连接到子图,而是可以使用 here.
  • 中描述的 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
}

生成以下输出: