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 : Stringl+ age : intl|+ die() : voidl}" ]; subgraph clusterAnimalImpl{ bgcolor="yellow" Dog [ label = "{Dog||+ bark() : voidl}" ]; Cat [ label = "{Cat||+ meow() : voidl}" ]; }; 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: Stringl+ age: Integerl|+ die(): voidl}" ] subgraph clusterAnimalImpl { label="Package animal.impl" Dog [ label = "{Dog||+ bark(): voidl}" ] Cat [ label = "{Cat||+ meow(): voidl}" ] { rank=same; Dog; Cat } } Dog -> Animal Cat -> Animal edge [ arrowhead = "none" headlabel = "0..*" taillabel = "0..*" ] Dog -> Cat }
图样二如下: