【graphviz笔记】用graphviz画UML类图

digraph UMLClassDiagram {
// 指定节点类型,这样节点才会变成UML的类图矩形
node [shape=record, fontname="Arial"];

// 定义节点数据
// 其中“|”会渲染成横线;
// \l表示向左对齐,同时换行
// \n表示居中对齐,同时换行
class1 [label="{
Class 1
|
+ attribute1: type\l
+ method1()\l
|
+ staticMethod(): returnType\l
}"];

class2 [label="{
Class 2|+ attribute2: type\l
- privateAttribute: type\l
|
+ method2()\l}
"];

class3 [label="{
Class 2|+ attribute2: type\l
- privateAttribute: type\l
|
+ method2()\l}
"];

class1 -> class2 [arrowhead="empty"]; // 空心箭头
class2 -> class3 [arrowhead="empty", style="dashed"]; // 空心虚线箭头(实现)
}

posted @ 2023-12-15 13:35  码鸽  阅读(228)  评论(0)    收藏  举报