注释说明很详细,不再详述!
digraph G{
  //dot 是一种绘图语言,它可以方便你采用图形的方式快速、直观地表达一些想法,
  //比如描述某个问题的解决方案,构思一个程序的流程,澄清一堆貌似散乱无章的事物之间的联系……等等。
  //总之,当你打算使用铅笔在纸上乱画一些圈圈框框并用一些带箭头的线将它们联系起来的时候,
  //不妨考虑一下使用 dot 来完成这个工作。
  //digraph 是 dot 用于定义有向图的命令,在这里它定义了一幅名为 G 的有向图,
  //花括号中所包含的内容即为该有向图的内容,也就是结点和边。
  //'->' 符号表示有向边,从一个结点指向另一个结点。
  //graph是 dot 用于定义无向图的命令。
  //'--'符号表示无向边。
  //1.定义一个图,并向图中添加需要的顶点和边
  //2.为顶点和边添加样式
  //3.使用布局引擎进行绘制
  //【1】图的属性
  //默认的顶点中的文字为顶点变量的名称,形状为椭圆; 边的默认样式为黑色实线箭头。
  label    = "图的属性设置示例";    //标签
  fontsize = 10;          //字体大小
  fontname = "Microsoft YaHei"; //字体名称
  //默认结点属性
  node [shape = Mrecord, style = filled, fillcolor = ".7 .3 1.0", color = green, fontsize = 10];
  //默认边属性
  edge [arrowsize = .5];  //箭头为原来的0.5
  //【1】 声明结点ID
  a[shape = component, color = green];  //形状为component 边框颜色为green
  b[shape = polygon, sides = 5, peripheries = 3];   //多边形 有五条边 3条边框
  c[shape = polygon, sides = 4, skew = 0.4, label="CC"];  //多边形 有四条边 倾斜角度为0.4 标签文本为CC
  d;
  e;
  f[shape = circle, color = red, style = solid]; //圆形 边框颜色为red
  
  //【2】 构造连接关系,采用 '->'  ,后面的[]中用于定义边的属性
  a->b[color="red"]; //边为red色
  a->c[style = dashed];  //边为虚线
  a->d[style = bold, label="100 times"]; //边加粗,线的标签为100 times
  b->e;  
  e->{f; d}; //同时连接两个
  b->s0[arrowhead = "normal", dir=both]; //边的箭头类型为正常类型,方位为双向
  
  //[3] 结点分组 -- 子图subgraph
  //子图的名称必须以cluster开头,否则graphviz无法设别。
  subgraph cluster_1{ 
    label = "process 1"; //子图的标签
    bgcolor="mintcream"; //子图的背景色
    s0->s1->s2;      //构造连接关系
  };
  //[4] 多条数据的记录 shape = "record"
  //采用'|'分割数据 '\l'换行
  Animal[label = "{Animal | + name : String\l+ age : int\l |+ die() : void\l}", shape = "record" ];
  subgraph clusterAnimalImpl{
    bgcolor = "yellow";
    Dog[label = "{Dog| |+ bark() : void\l}" , shape = "record"];
    Cat[label = "{Cat| |+ meow() : void\l}" , shape = "record"];
  };  
  edge[arrowhead = "empty"];
  Dog->Animal;
  Cat->Animal;
  Dog->Cat[arrowhead="none", label="0..*"];
}效果图:

更多参考:
安装完Graphviz软件后,在安装目录的..\Graphviz\share\graphviz\doc\html,获取更多的参考资料。










