graphviz画数据结构关系图

graphviz画数据结构关系图

模板整理一下
用到了node的属性有:
shape
label 加{ }表示field竖向排列,不加表示横向排列。
color
color建议使用rgb的方式设置: color=”#0033ff“
style
style的值可以有filled,
用到了edge的属性有:
dir
label

digraph snd_config {
	node [shape=record];
	rootconfig [label="{root\nstruct _snd_config| char *id\ntype=compound}", color=lightblue, style=filled];
	comchildconfig [label="{ struct _snd_config| char *id\ntype=compound}"];
	strchildconfig [label="{ struct _snd_config| char *id\ntype=string}"];
	intchildconfig [label="{ struct _snd_config| char *id\ntype=interger}"];

	sstrchildconfig [label="{ struct _snd_config| char *id\ntype=string}"];
	sintchildconfig [label="{ struct _snd_config| char *id\ntype=interger}"];
	scomchildconfig [label="{ struct _snd_config| 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="{struct _snd_mixer|compare=snd_mixer_compare_default}", color=lightblue, style=filled];
	snd_hctl [label="{ struct _snd_hctl| compare=snd_hctl_compare_default\ncallback=hctl_event_handler}"];
	snd_ctl [label="{ struct _snd_ctl|ops=snd_ctl_hw_ops }"];
	snd_mixer_slave [label="{ struct _snd_mixer_slave| }"];
	snd_mixer_class [label="{ struct _snd_mixer_class|event=simple_event\ncompare=snd_mixer_selem_compare}"];
	snd_hctl_elem_pointer_array [label="struct _snd_hctl_elem*| | | ||"];
	snd_hctl_elem [label="{ struct _snd_hctl_elem| callback=hctl_elem_event_handle}"]; 
	snd_ctl_elem_list [label="{ struct _snd_ctl_elem_list|}"];
	snd_ctl_elem_id [label="{ struct _ctl_elem_id\n(struct _snd_hctl_elem template)| | | | |}"]

	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"]
}

参考:
https://www.jianshu.com/p/6d9bbbbf38b1

你可能感兴趣的:(Linux,tools)