用Graphviz画简单依赖图示例


代码:

digraph module {

0 [label="global.h"];
1 [label="bst_operator.c"];
2 [label="cnf_parser.c"];
3 [label="puzzle2cnf.c"];
4 [label="puzzle_generate.c"];
5 [label="puzzle_main.c"];
6 [label="sat_solver.c"];
7 [label="sat_main.c"];
8 [label="dispay.c"];

node [shape="record"];
9 [label="puzzle_generate.exe"];
10 [label="puzzle_main.exe"];
11 [label="sat_main.exe"];
12 [label="display.exe"];

edge [label="被引用", style="dashed", fontname="Microsoft YaHei"];
{0 6 1} -> 2;
3 -> {4 5};
{0 2 6} -> 7;
{0 1} -> 6;

edge [label="被运行", style="dashed", fontname="Microsoft YaHei"];
{9, 10 11} -> 8;
11 -> {4 5};

edge [label="编译", style="bold", fontname="Microsoft YaHei"];
4 -> 9;
5 -> 10;
7 -> 11;
8 -> 12;

}

编译:

dot -Tsvg source.dot -o picture.svg

source.dot是代码文件,picture.svg是输出的矢量图,也可以将svg改成png输出像素图。

效果: