0%

从零开始的Dot可视化历险

1. 基本使用实例

1.1 一个C程序的内部调用图

如图1.1.a 所示

demo.dotview raw
1
2
3
4
5
6
7
8
9
10
digraph G {
main -> parse -> execute;
main -> init;
main -> cleanup;
execute -> make_string;
execute -> printf;
init -> make_string;
main -> printf;
execute -> compare;
}

如图1.1.b 所示

demo_enhance.dotview raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
digraph G {
size = "4,4";
main [shape=box]; /* this is a comment*/
main -> parse [weight=8];
parse -> execute;
main -> init [style=dotted];
main -> cleanup;
execute -> { make_string; printf };
init -> make_string;
edge [color=red];
main -> printf [style=bold,label="100 times"];
make_string [label="make a\nstring"];
node [shape=box,style=filled,color=".7,.3,1.0"];
execute -> compare;
}

2. 从基本结构开始探险

2.1 Node

如图 2.1.a 所示

1
2
3
4
5

diagraph G {
main [label="我是一个☝️节点,名字叫做main"]
}