dot 绘制链表插入图
新建 test.dot 文件,代码如下
digraph structs {
size = "16,8";
node [shape=record];
struct1 [label="<f0> new | <f1> struct list_head *prev; | <f2> struct list_head *next;"];
struct2 [label="<f0> prev | <f1> struct list_head *prev; | <f2> struct list_head *next;"];
struct3 [label="<f0> next | <f1> struct list_head *prev; | <f2> struct list_head *next;"];
struct1:f1:w -> struct2:f0:w[style=dotted,color=blue];
struct1:f2:w -> struct3:f0:w[style=solid,color=green];
struct2:f2:e -> struct1:f0:e[style=dashed,color=green];
struct3:f1:e -> struct1:f0:e[style=bold,color=lightblue];
{rank=same;struct1;struct2;struct3}
rankdir=LR
}
可以使用命令生成图片
==dot -Tpng test.dot -o test.png==
或者新建 dot.bat,代码如下
dot.exe -Tpng test.dot -o test.png
PS:
这里的 dot.exe 可以使用 安装 graphviz 在 Program Files (x86)\Graphviz2.38\bin\dot.exe 中拷贝到 与 test.dot 在相同目录文件下即可。
生成的 test.png 如下
可以参考如下的链接:
dot 官网
Graphviz样例之UML图