dot 语法全介绍

0. 保存

  • 保存为 pdf:dot -Tpdf iris.dot -o iris.pdf

1. 基本

  • (1)无向图、有向图、子图

    graph G {}   // 无向图
    digraph G {} // 有向图
    digraph G {
        subgraph cluster_0 {}
        subgraph cluster_1 {}
    }
  • (2)形状

    • box ⇒ 长方形
    • circle ⇒ 圆
    v1 [label = "v1", shape = "circle"]
  • (3)箭头上指示文字和颜色:

    T -> P [label = "Instructions", fontcolor=darkgreen];

2. 高级

  • (1)统一设置结点类型、边类型

    node [shape = box, color = red, fontname = Courier]
    edge [color = blue, shape = dashed]

3. 其他

  • 排列方式(默认是纵向):

    rankdir = LR; // 也即从左到右,设置为横向

references

Graphviz 画图和例子
使用graphviz dot来画图表

原文地址:https://www.cnblogs.com/mtcnn/p/9423958.html