Graphviz样例之UML图
Graphviz是一个开源软件,有源码,支持不同平台。linux系统下使用XDot程序显示dot格式的文件。
Graphviz显示图形时,可以选择不同的策略进行布局和布线显示图形。
Graphviz的官方网站(点击进入):Graphviz | Graphviz
 - Graph Visualization Software。
Web版的Graphviz网站(点击进入):Webgraphviz。
UML图(两种)
代码一如下:
digraph UML {
     
    fontname = "Courier New"
    fontsize = 10
     
    node [ fontname = "Courier New", fontsize = 10, shape = "record" ];
    edge [ fontname = "Courier New", fontsize = 10 ];
     
    Animal [ label = "{Animal |+ name : String\l+ age : int\l|+ die() : void\l}" ];
    
       subgraph clusterAnimalImpl{
           bgcolor="yellow"
           Dog [ label = "{Dog||+ bark() : void\l}" ];
           Cat [ label = "{Cat||+ meow() : void\l}" ];
       };
    
   edge [ arrowhead = "empty" ];
    
   Dog->Animal;
   Cat->Animal;
   Dog->Cat [arrowhead="none", label="0..*"];
}图样一如下:
代码二如下:
digraph UML2 {
	nodesep=0.8;
	node [ fontname="Bitstream Vera Sans", fontsize=8, shape="record" ]
	edge [
		fontsize=8
		arrowhead="empty"
	]
	Animal [
		label = "{Animal|+ name: String\l+ age: Integer\l|+ die(): void\l}"
	]
	subgraph clusterAnimalImpl {
		label="Package animal.impl"
		Dog [
			label = "{Dog||+ bark(): void\l}"
		]
		Cat [
			label = "{Cat||+ meow(): void\l}"
		]
		{ rank=same; Dog; Cat }
	}
	Dog -> Animal
	Cat -> Animal
	edge [
		arrowhead = "none"
		headlabel = "0..*"
		taillabel = "0..*"
	]
	Dog -> Cat
}图样二如下:
 
                     
                    
                 
                    
                 
                
            
         
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号