版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dongkun152/article/details/83051231
graphviz画数据结构关系图
模板整理一下
用到了node的属性有:
shape
label 加{ }表示field竖向排列,不加表示横向排列。
color
style
用到了edge的属性有:
dir
label
digraph snd_config {
node [shape=record];
rootconfig [label="{<e1>root\nstruct _snd_config|<e2> char *id\ntype=compound}", color=lightblue, style=filled];
comchildconfig [label="{<e1> struct _snd_config|<e2> char *id\ntype=compound}"];
strchildconfig [label="{<e1> struct _snd_config|<e2> char *id\ntype=string}"];
intchildconfig [label="{<e1> struct _snd_config|<e2> char *id\ntype=interger}"];
sstrchildconfig [label="{<e1> struct _snd_config|<e2> char *id\ntype=string}"];
sintchildconfig [label="{<e1> struct _snd_config|<e2> char *id\ntype=interger}"];
scomchildconfig [label="{<e1> struct _snd_config|<e2> char *id\ntype=compound}"];
rootconfig -> comchildconfig[dir="both",label="fields"];
comchildconfig -> strchildconfig[dir="both",label="list"];
strchildconfig -> intchildconfig[dir="both", label="list"];
comchildconfig -> sstrchildconfig[dir="both", label="fields"];
sstrchildconfig -> sintchildconfig[dir="both", label="list"];
sintchildconfig -> scomchildconfig[dir="both", label="list"];
}
保存文件为config.dot
编译:
dot -Tpng config.dot -o config.png
模板记录
指定filed中箭头的起点和终点位置。
nodename:field:position position可以的取值是n,s,w,e(东西南北),nw,ne等等。
digraph alsa_mixer {
node [shape=record];
snd_mixer [label="{<e1>struct _snd_mixer|<e2>compare=snd_mixer_compare_default}", color=lightblue, style=filled];
snd_hctl [label="{<e1> struct _snd_hctl|<e2> compare=snd_hctl_compare_default\ncallback=hctl_event_handler}"];
snd_ctl [label="{<e1> struct _snd_ctl|<e2>ops=snd_ctl_hw_ops }"];
snd_mixer_slave [label="{<e1> struct _snd_mixer_slave|<e2> }"];
snd_mixer_class [label="{<e1> struct _snd_mixer_class|<e2>event=simple_event\ncompare=snd_mixer_selem_compare}"];
snd_hctl_elem_pointer_array [label="<e1>struct _snd_hctl_elem*|<e2> |<e3> |<e4> |<e5>|"];
snd_hctl_elem [label="{<e1> struct _snd_hctl_elem|<e2> callback=hctl_elem_event_handle}"];
snd_ctl_elem_list [label="{<e1> struct _snd_ctl_elem_list|<e2>}"];
snd_ctl_elem_id [label="{<e1> struct _ctl_elem_id\n(struct _snd_hctl_elem template)|<e2> |<e3> |<e4> |<e5> |}"]
snd_ctl_elem_list:e2:e -> snd_ctl_elem_id:e1:n[label="pids"];
snd_mixer:e2:w -> snd_mixer_class:e2:w[color="red",dir="both",label="classes"];
snd_mixer:e2:w -> snd_mixer_slave:e2:w[color="red",dir="both",label="slave"];
snd_mixer_class:e2:e -> snd_mixer:e2:e[label="mixer"];
snd_mixer_slave:e2:e -> snd_hctl:e1:w [label="hctl"];
snd_hctl:e2:w -> snd_mixer:e1:e[label="callback_private"];
snd_hctl:e2:e -> snd_hctl_elem_pointer_array:e2:nw[label="pelems"];
snd_hctl:e2:w -> snd_ctl:e2:w[label="ctl"];
snd_hctl:e2:e -> snd_hctl_elem:e2:w[color="red", dir="both", label="elems"]
snd_hctl_elem_pointer_array:e2:s -> snd_hctl_elem:e1:w;
snd_hctl_elem:e2:w -> snd_hctl:e2:e[label="hctl"]
}