使用 GraphViz 创建复杂的包图

Create a complex package diagram with GraphViz

我想使用点语言创建一个包图,类似于下图。 我知道可以使用 "clusters" 嵌套元素,但不确定是否可以将标签放在外包装的标签区域中。 让我知道是否可行。

遗憾的是 tab 形状(耳朵在左上角的那个)不支持在那里指定标签。

如果你愿意牺牲那个,你可以使用常规矩形或记录形状

digraph diagram {
    compound=true;
    ranksep=1
    node[shape=record]

    subgraph cluster_all {
        label="Multi-Layered Application"
        Users [shape=tab]

        subgraph cluster_presentation {
            label="Presentation Layer"
            "User Interface" [shape=tab]
            "Presentation Logic" [shape=tab]
        }

        Users -> "User Interface" [lhead=cluster_presentation]

        subgraph cluster_business {
            label="Business Layer"
            node[shape=tab]
            "Application Facade"
        }

        "User Interface" -> "Application Facade" [lhead=cluster_business,ltail=cluster_presentation,style=dashed]
    }

}

但如您所见,graphviz 并不完全适合此操作,因为您需要进行大量低级操作。

或者,如果 objective 是用文本描述图表,我强烈推荐 plantuml.com,它的语法更适合此类任务。

@startuml
package "<<model>> Multi-Layered Application <<model>>" as app {
  package Users { }

  package "Presentation Layer" as presentation {
    package "User Interface" { }
    package "Presentation Logic" { }
  }

  Users ..> presentation

  package "Business Layer" {
    package "Application Facade" { }
  }

  presentation ..> "Business Layer"

}
@enduml