子图未出现在 graphviz 图表中

问题描述 投票:0回答:1

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

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
}

我不明白,与底部图相比,顶部图有什么不同,底部可以工作,但顶部不行。我已经把眼睛挖出来了。我没有看到这里的问题。

请帮忙

graph charts graphviz
1个回答
2
投票

几个问题:

  • 子图名称必须以关键字
    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
}

生成以下输出:

graph

© www.soinside.com 2019 - 2024. All rights reserved.