1:vimdot noname.dot
1 digraph G {
2 graph [layout=dot rankdir=LR]
3
4 // This is just an example for you to use as a template.
5 // Edit as you like. Whenever you save a legal graph
6 // the layout in the graphviz window will be updated.
7
8 vim [href="http://www.vim.org/"]
9 dot [href="http://www.graphviz.org/"]
10 vimdot [href="file:///usr/bin/vimdot"]
11
12 {vim dot} -> vimdot
13 }
pic1:
you can connect to the href!
2:vim htm.dot
digraph html {
A -> B[dir = both];
B -> C[dir = none];
C -> D[dir = back];
D -> A[dir = forward];
}
3:[root@centosTest dottest]# vim
1 digraph G {
2 a -> b -> c;
3 b -> d;
4 a [shape=polygon,sides=5,peripheries=3,color=lightblue,style=filled];
5 c [shape=polygon,sides=4,skew=.4,label="hello world"]
6 d [shape=invtriangle];
7 e [shape=polygon,sides=4,distortion=.7];
8 }
vimdot sharp.dot
4:复杂形式
digraph structs {
node [shape=record];
struct1 [shape=record,label="<f0> left|<f1> mid\ dle|<f2> right"];
struct2 [shape=record,label="<f0> one|<f1> two"];
struct3 [shape=record,label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
struct1 -> struct2;
struct1 -> struct3;
}
vimdot pro.dot
d
5:横向排列
digraph html {
rankdir = LR;
{
node[shape = plaintext];
1995 -> 1996 -> 1997 -> 1998 -> 1999 -> 2000 -> 2001;
}
{
node[shape = box, style = filled];
WAR3 -> Xhero -> Footman -> DOTA;
WAR3 -> Battleship;
}
{rank = same; 1996; WAR3;}
{rank = same; 1998; Xhero; Battleship;}
{rank = same; 1999; Footman;}
{rank = same; 2001; DOTA;}
}
6:操作系统进程转化图
[root@centosTest dottest]# vim process.dot
1 graph G {
2 run -- intr;
3 intr -- runbl;
4 runbl -- run;
5 run -- kernel;
6 kernel -- zombie;
7 kernel -- sleep;
8 kernel -- runmem;
9 sleep -- swap;
10 swap -- runswap;
11 runswap -- new;
12 runswap -- runmem;
13 new -- runmem;
14 sleep -- runmem;
15 }
~
---
示例二 操作系统的进程状态转换图
下面的例子来自http://www.graphviz.org/Gallery/undirected/process.html 。
[root@jfht ~]# cat process.gv
graph G {
run -- intr;
intr -- runbl;
runbl -- run;
run -- kernel;
kernel -- zombie;
kernel -- sleep;
kernel -- runmem;
sleep -- swap;
swap -- runswap;
runswap -- new;
runswap -- runmem;
new -- runmem;
sleep -- runmem;
}
[root@jfht ~]# dot -Tpng -oprocess.png process.gv
Format: "png" not recognized. Use one of: canon cmap cmapx cmapx_np dot eps fig gd gd2 gif gv imap imap_np ismap plain plain-ext ps ps2 svg svgz tk vml vmlz wbmp xdot
[root@jfht ~]# dot -Tgif -oprocess.gif process.gv
[root@jfht ~]# dot -Tsvg -oprocess.svg process.gv
[root@jfht ~]#
-- 下面的几个例子都来自于官方文档。详情请见:Graphviz官网.
[root@centosTest dottest]# vim fanc.dot
1 digraph G{
2
3 size = "4, 4";//图片大小
4 main[shape=box];/*形状*/
5
6 main->parse;
7 parse->execute;
8
9 main->init[style = dotted];//虚线
10
11 main->cleanup;
12
13 execute->{make_string; printf}//连接两个
14
15 init->make_string;
16
17 edge[color = red]; // 连接线的颜色
18
19 main->printf[style=bold, label="100 times"];//线的 label
20
21 make_string[label = "make a\nstring"]// \n, 这个node的label,注意和上一行的区别
22
23 node[shape = box, style = filled, color = ".7.3 1.0"];//一个node的属性
24
25 execute->compare;
26 }
http://www.cnblogs.com/sld666666/archive/2010/06/25/1765510.html
连接点的方向
我们可以用“n”,”ne”,”e”,””se”, “sw”,”w”,”nw”,
分别表示冲哪一个方向连接这个节点(图形)-“north, northeast……”
如:
digraph G{
//b->c[tailport = se];
b->c:se;
}
<图3. Se graph>
来自zoom quite的一个复杂例子
[root@centosTest dottest]# more dama.dot
digraph knoss2talking {
/*生成命令:
$ dot -Tpng knoss2talking.dot -o knoss2talking.jpg -Tcmapx -o knoss2talking.map
全局设定
*/
graph [label="开源卫士社区语音讲座 内容关系图谱 \n{powerded by graphviz 2.28.0}"
,fontsize=14.0,fontcolor=snow
,labeljust="l",labelloc="t",center=1
,ranksep=0.1,ratio=compress
,rankdir=LR
,truecolor bgcolor="#333333"
];
node[fontsize=11.0,height=0.1
,style="filled,setlinewidth(0.5)",fillcolor="#333333",color=gray,fontcolor=snow
,shape=plaintext
];
edge [fontsize=9.0,fontcolor=gray
,color=azure
,arrowsize=0.4,arrowhead=vee,arrowtail=none
,style="setlinewidth(0.5)"
];
src [label="源码",shape=ellipse,style="filled,dashed,setlinewidth(5)"
,color="#333333",fillcolor=dimgray
,URL="http://code.google.com/p/zoomquiet/source/browse/dot/4kavass/knoss2talking.dot?repo=tangle"];
root [label="bbs.code.ijinshan.com\nYY频道:84544119",shape=box3d];
community [label="社区",shape=tab];
windows [label="Windows系统",shape=tab];
weishi [label="卫士",shape=tab];
WTL [label="WTL框架",shape=tab];
bkWin [label="bkWin框架",shape=tab];
KSC [label="云安全",shape=tab];
example [label="实案",shape=tab];
browse [label="浏览器插件",shape=tab];
PaaS [label="PaaS",shape=tab];
nodejs [label="node.js",shape=tab
,URL="http://nodejs.org/"];
openresty [label="OpenResty",shape=tab
,URL="http://openresty.org/"];
GAE [label="GAE",shape=tab
,URL="http://nodejs.org/"];
SAE [label="SAE",shape=tab
,URL="https://appengine.google.com/"];
root->{community windows weishi KSC};
weishi->{WTL bkWin};
KSC->example->{browse PaaS};
vol1 [label="让互联网拥抱安全",URL="http://code.ijinshan.com/trac/wiki/TalkKavass/InitYy"];
vol1s [label="幻灯",URL="http://code.ijinshan.com/res/r/101222-yy-knoss/"];
vol1r1 [label="中大录音",URL="http://code.ijinshan.com/res/r/101204_114M_CCF.YOCSEF-KCS.MP3"];
vol1r2 [label="上海录音",URL="http://code.ijinshan.com/res/r/101218-oscamp-shanghai/101218_124M_3-zoomquiet.MP3"];
vol1r3 [label="YY录音",URL="http://code.ijinshan.com/res/r/101222-yy-knoss/101223_133M_yy-zq-knoss.MP3"];
community->vol1->vol1s;
vol1->vol1r1 [label="101204"];
vol1->vol1r2 [label="101218"];
vol1->vol1r3 [label="101231"];
vol2 [label="社区平台详解"
,URL="http://code.ijinshan.com/trac/wiki/TalkKavass/InitHg"];
vol3 [label="卫士系统优化的实现"
,URL="http://www.slideshare.net/Zoom.Quiet/110329-luopengsysoptopenkavass"];
vol4 [label="深入理解windows窗口和消息机制"
,URL="http://code.ijinshan.com/res/r/110407-yy-wtl/110407-liupeng-diveinto-wtl.pdf"];
vol5 [label="Hg基础及远程協同"
,URL="http://code.ijinshan.com/res/m/110412-knoss-hg-howto/"];
vol6 [label="WTL开发技巧"
,URL="http://code.ijinshan.com/trac/blog/yy-vol6-wtl"];
vol7 [label="WTL对象映射"
,URL="http://bbs.code.ijinshan.com/thread-1085-1-1.html"];
vol8 [label="WTL对话框"
,URL="http://bbs.code.ijinshan.com/thread-1098-1-1.html"];
vol9 [label="WTL对话框控件使用"
,URL="http://bbs.code.ijinshan.com/thread-1107-1-1.html"];
vol10 [label="WTL控件绘制基础"
,URL="http://bbs.code.ijinshan.com/thread-1118-1-1.html"];
vol11 [label="WTL之VFC简介"
,URL="http://bbs.code.ijinshan.com/thread-1127-1-1.html"];
vol12 [label="WTL非窗口化控件实现"
,URL="http://bbs.code.ijinshan.com/thread-1143-1-1.html"];
vol13 [label="如何看开源卫士代码"
,URL="http://bbs.code.ijinshan.com/thread-1161-1-1.html"];
vol14 [label="WTL再谈自绘控件"
,URL="http://bbs.code.ijinshan.com/thread-1177-1-1.html"];
vol15 [label="再看开源卫士代码"
,URL="http://bbs.code.ijinshan.com/thread-1207-1-2.html"];
vol16 [label="如何在工程中使用bkwin"
,URL="http://bbs.code.ijinshan.com/thread-1209-1-2.html"];
vol17 [label="windows平台下调试工具"
,URL="http://bbs.code.ijinshan.com/thread-1220-1-2.html"];
vol18 [label="如何用bkwin完成tab效果"
,URL="http://bbs.code.ijinshan.com/thread-1230-1-2.html"];
vol19 [label="如何进行windows驱动开发"
,URL="http://bbs.code.ijinshan.com/thread-1247-1-1.html"];
vol20 [label="ELF开发"
,URL="http://bbs.code.ijinshan.com/thread-1251-1-1.html"];
vol21 [label="ELF开发续"
,URL="http://bbs.code.ijinshan.com/thread-1258-1-1.html"];
vol22 [label="Windows系统机制"
,URL="http://bbs.code.ijinshan.com/thread-1308-1-1.html"];
vol23 [label="缓存管理器理解"
,URL="http://bbs.code.ijinshan.com/thread-1313-1-1.html"];
vol24 [label="Windows系统机制再谈"
,URL="http://bbs.code.ijinshan.com/thread-1349-1-1.html"];
vol25 [label="缓存管理器理解再来"
,URL="http://bbs.code.ijinshan.com/thread-1355-1-1.html"];
vol26 [label="C++运行库理解"
,URL="http://bbs.code.ijinshan.com/thread-1374-1-1.html"];
vol27 [label="bkWin小实例"
,URL="http://bbs.code.ijinshan.com/thread-1383-1-1.html"];
vol28 [label="Chrome插件开发基础"
,URL="http://bbs.code.ijinshan.com/thread-1424-1-3.html"];
vol29 [label="Chrome插件开发实例"
,URL="http://bbs.code.ijinshan.com/thread-1427-1-2.html"];
vol30 [label="WTL基础-1"
,URL="http://bbs.code.ijinshan.com/thread-1431-1-2.html"];
vol31 [label="bkWin的DirectUI实现原理"
,URL="http://bbs.code.ijinshan.com/thread-1436-1-2.html"];
vol32 [label="WTL基础-2"
,URL="http://bbs.code.ijinshan.com/thread-1440-1-2.html"];
vol33 [label="WTL基础-3"
,URL="http://bbs.code.ijinshan.com/thread-1456-1-2.html"];
vol34 [label="换肤编辑器"
,URL="http://bbs.code.ijinshan.com/thread-1472-1-2.html"];
vol35 [label="WTL基础-4"
,URL="http://bbs.code.ijinshan.com/thread-1496-1-2.html"];
vol36 [label="换肤编辑器再解"
,URL="http://bbs.code.ijinshan.com/thread-1505-1-2.html"];
vol37 [label="WTL基础-5"
,URL="http://bbs.code.ijinshan.com/thread-1518-1-1.html"];
vol38 [label="SAE云安全初步"
,URL="http://bbs.code.ijinshan.com/thread-1537-1-1.html"];
vol39 [label="SAE云安全小改"
,URL="http://bbs.code.ijinshan.com/thread-1547-1-1.html"];
vol40 [label="Velocity2011分享"
,URL="http://bbs.code.ijinshan.com/thread-1563-1-1.html"];
vol41 [label="网址云安全扫描案例"
,URL="http://bbs.code.ijinshan.com/thread-1570-1-1.html"];
vol42 [label="网址云安node.js结合"
,URL="http://bbs.code.ijinshan.com/thread-1578-1-1.html"];
vol43 [label="网址云结合mongo"
,URL="http://bbs.code.ijinshan.com/thread-1590-1-1.html"];
vol44 [label="网址云结合GAE"
,URL="http://bbs.code.ijinshan.com/thread-1609-1-1.html"];
vol45 [label="网址云嵌入Nginx"
,URL="http://bbs.code.ijinshan.com/thread-1647-1-1.html"];
vol46 [label="金山云安全架构"
,URL="http://bbs.code.ijinshan.com/thread-1682-1-1.html"];
vol47 [label="NAE云架构"
,URL="http://bbs.code.ijinshan.com/thread-1734-1-1.html"];
vol48 [label="盛大云架构"
,URL="http://bbs.code.ijinshan.com/thread-1763-1-1.html"];
vol49 [label="SAE存储演化"
,URL="http://bbs.code.ijinshan.com/thread-1860-1-1.html"];
vol50 [label="网址云植入NAE"
,URL="http://bbs.code.ijinshan.com/thread-1873-1-1.html"];
vol51 [label="网址云由KVDB在SAE加速"
,URL="http://bbs.code.ijinshan.com/thread-1887-1-1.html"];
vol52 [label="网址云用go"
,URL="http://bbs.code.ijinshan.com/thread-1899-1-1.html"];
vol53 [label="Infoc变迁"
,URL="http://bbs.code.ijinshan.com/thread-1954-1-1.html"];
weishi->{vol3 vol13 vol15 vol34 vol35};
WTL->{vol6 vol7 vol8 vol9 vol10 vol11 vol12 vol14 vol30 vol32 vol33 vol37};
bkWin->{vol16 vol18 vol27 vol31};
KSC->{vol1 vol40 vol46 vol53};
browse->{vol20 vol21 vol28 vol29};
PaaS->{nodejs GAE SAE openresty vol48};
SAE->{vol38 vol39 vol41 vol49 vol51};
nodejs->{vol42 vol43 vol47 vol50};
GAE->{vol44 vol52};
openresty->{vol45}
community->{vol2 vol5};
windows->{vol4 vol17 vol19 vol22 vol23 vol24 vol26};
{bbk1win bbk2win bbk1wtl bbk2wtl bbk3wtl bbk4wtl bbk5wtl bbk6wtl bbk7wtl}->Boobooke [style="dotted"];
vol30->bbk1wtl;
vol32->{bbk2wtl bbk3wtl};
vol33->bbk4wtl;
vol35->bbk5wtl;
vol37->{bbk6wtl bbk7wtl};
{vol1 vol2 vol5 vol28 vol29 vol38 vol39 vol41 vol42 vol43 vol44 vol45 vol50 vol51 vol52}->ZQ [color=skyblue];
{vol4 vol6 vol7 vol11 vol13 vol15 vol17}->LiuP [color=blue];
{vol8 vol9 vol10 vol12 vol14 vol16 vol18 vol31}->CGC [color=green];
{vol40 vol46 vol53}->PRC [color=red];
{vol30 vol32 vol35 vol37}->ZZX;
{vol20 vol21}->LS;
{vol22 vol24}->QW;
{vol23 vol25}->ZWJ;
{vol34 vol36}->LFF;
{vol27}->LXD;
{vol19}->SWJ;
{vol26}->YJ;
{vol3}->LP;
{LP SWJ QW ZWJ LFF LXD YJ}->intraTalkers;
PRC->intraTalkers [style="setlinewidth(1)"];
ZZX->intraTalkers [style="setlinewidth(2)"];
LiuP->intraTalkers [style="setlinewidth(3)"];
CGC->intraTalkers [style="setlinewidth(3)"];
ZQ->intraTalkers [style="setlinewidth(4)"];
intraTalkers [label="金山讲师"];
ZQ [label="Zoom.Quiet",URL="http://zoomquiet.org"];
LP [label="罗鹏",URL="http://code.ijinshan.com/trac/wiki/LuoPeng"];
LiuP [label="刘鹏",URL="http://code.ijinshan.com/trac/wiki/LiuPeng"];
PRC [label="彭仁诚",URL="http://weibo.com/charlespeng"];
CGC [label="桂城",URL="http://code.ijinshan.com/trac/wiki/ChenGuiCheng"];
SWJ [label="苏文杰",URL="#"];
ZWJ [label="张文君",URL="#"];
QW [label="祁伟",URL="#"];
YJ [label="杨军",URL="#"];
LXD [label="刘新典",URL="#"];
ZZX [label="张泽鑫",URL="#"];
LFF [label="梁放放",URL="#"];
{LS kobe duhai LiDaobing qingdu}->interTalkers [color=yellow];
Boobooke->interTalkers [style="dotted,setlinewidth(1)"];
vol47->qingdu;
vol48->{duhai LiDaobing};
vol49->kobe;
interTalkers [label="网络讲师"];
Boobooke [label="布客",URL="boobooke.html"];
LS [label="LuciferStar",URL="http://bbs.duba.net/thread-21861751-1-1.html"];
kobe [label="丛磊",URL="#"];
duhai [label="杜海",URL="#"];
LiDaobing [label="LI Daobing",URL="http://qa.debian.org/developer.php?login=lidaobing@debian.org"];
qingdu [label="清笃",URL="http://club.cnodejs.org/user/qingdu"];
bbk1wtl [label="WTL入门.1",URL="http://www.boobooke.com/v/bbk5230"];
bbk2wtl [label="WTL入门.2",URL="http://www.boobooke.com/v/bbk5240"];
bbk3wtl [label="WTL入门.3",URL="http://www.boobooke.com/v/bbk5251"];
bbk4wtl [label="WTL入门.4",URL="http://www.boobooke.com/v/bbk5264"];
bbk5wtl [label="WTL入门.5",URL="http://www.boobooke.com/v/bbk5265"];
bbk6wtl [label="WTL入门.6",URL="http://www.boobooke.com/v/bbk5402"];
bbk7wtl [label="WTL入门.7",URL="http://www.boobooke.com/v/bbk5403"];
bbk1win [label="bkWin实战:1",URL="http://www.boobooke.com/shop/?product-bbk5277.html"];
bbk2win [label="bkWin实战:1",URL="http://www.boobooke.com/shop/?product-bbk5278.html"];
/*
nodeA->nodeB [label="日常",color=azure,style="setlinewidth(1)"];
nodeA->nodeB [label="活跃",color=azure,style="setlinewidth(2)"];
nodeA->nodeB [label="兴奋",color=azure,style="setlinewidth(3)"];
src->wares;
*/
edge [style=invis];
}
[root@centosTest dottest]#