[TOC]
DOT语言是一种文本图形描述语言它提供了一种简单的描述图形的方法,并且可以为人类和计算机程序所理解。DOT语言文件通常是具有.gv或是.dot的文件扩展名。很多程序都可以处理DOT文件。
graphviz(Graph Visualization Software) 是一个由AT&T实验室启动的开源工具包,用于绘制DOT语言脚本描述的图形。
Graphviz语法主要由以下部分组成:
代码块位于{}中的语句即为代码块;语句以;结尾,主要分为代码块,节点,连线,属性四种语句类型;实体对象标识符除了特殊字符外的所有字符都可以用于标识符,如数字,中英文字符串等;注释//表示单行注释,/*...*/表示多行注释。
| 属性名 | 默认值 | 说明 |
|---|---|---|
| label | name name | 节点显示内容 |
| color | black | node边框颜色 |
| fontcolor | black | 字体颜色 |
| fillcolor | 背景色 | |
| fontname | Times-Roman | 字体 |
| fontsize | 14 | 字体大小 |
| shape | ellipse | 形状: - box - box3d - cds - circle - component - diamond - doublecircle - doubleoctagon - egg - ellipse - folder - hexagon - house - invhouse - invtrapezium - invtriangle - Mcircle - Mdiamond - Msquare - none - note - octagon - oval - parallelogram - pentagon - plain - plaintext - point - polygon - promoter - rect - rectangle - septagon - square - star - tab - trapezium - triangle - tripleoctagon - underline |
| style | 图形样式: - eg.bold - dashed - dotted - filled |
|
| height | .5 | 最低高度尺寸 |
| width | .75 | 最低宽度尺寸 |
| URL | 点击跳转地址 | |
| target | 点击跳转打开方式 | |
| image | 背景图片地址 |
例:

| 属性名 | 默认值 | 说明 |
|---|---|---|
| label | 描述关系 | |
| color | black | 箭头颜色 |
| fontcolor | black | 关系文件颜色 |
| dir | forward | 设置方向: - forward - back - both - none |
| arrowhead | normal | 箭头头部形状: - box - crow - diamond - dot - none - normal - vee |
| arrowtail | 箭头尾部形状 | |
| arrowsize | 1.0 | 箭头大小 |
| style | 图形样式: - eg.bold - dashed - dotted - filled |
|
| lhead | 当 compound 为true时,lhead用于指定边指向的cluster | |
| ltail | 与ltail类似 |

起点:

方向:

尺寸:
ranksep相邻 rank 之间的距离;
间距:
nodesep同一个 rank 中的相邻节点的最小距离,单位为英寸(=2.54 cm)。直线的不同端点属于不同的 rank;

graph图digraph {...}有向图;graph {...}无向图;
subgraph子图;
| 属性名 | 默认值 | 说明 |
|---|---|---|
| bgcolor | 背景颜色 | |
| compound | false | 配合lhead和ltail使用 |
| fontcolor | black | 字体颜色 |
| fontname | Times-Roman | 字体 |
| fontsize | 14 | 字体大小 |
| label | 图片标签 | |
| layout | 布局引擎 | |
| rank | 子图等级限制: - same - min - max - source - sink |
|
| rankdir | TB | 排序方向: - LR - TB |
| ratio | 垂直夸大率浮点数: - fill - compress - auto |
|
| size | 最大大小(英寸) |
例:

|分隔符<>锚点{}竖型排列
