Graphviz dot,使用dot语言快速生成图表

来源:互联网 发布:1122uh域名升级中 编辑:程序博客网 时间:2024/05/16 01:53

这便是我们今天的主角, 也就是最后的效果图

简要的步骤如下:

  • 打开http://www.graphviz.org/下载所在平台的Graphviz
  • 如果是windows及编译的等,可能需要加入系统路径
  • 确保其能运行dot命令

关于Graphviz: Graphviz (英文:Graph Visualization Software的缩写)是一个由AT&T实验室启动的开源工具包,用于绘制DOT语言脚本描述的图形。它也提供了供其它软件使用的库。Graphviz是一个自由软件,其授权为Eclipse Public License。其Mac版本曾经获得2004年的苹果设计奖。

(转载请标源自 Phodal's Blog

graph example1 {    Server1 -- Server2    Server2 -- Server3    Server3 -- Server1}

结果如图所示: 

如何生成?

dot example1.dot –Tpng –o example1.png

根据生成的不同格式选择不同的输出方式

dot example1.dot –Tbmp –o example1.bmp

最后让我们看一下开头那个:

    digraph g {graph [rankdir = "LR"];node [fontsize = "16"shape = "ellipse"];edge [];"node0" [label = " 0x10ba8| "shape = "record"];"node1" [label = " 0xf7fc4380|  |  |-1"shape = "record"];"node2" [label = " 0xf7fc44b8| | |2"shape = "record"];"node3" [label = " 3.43322790286038071e-06|44.79998779296875|0"shape = "record"];"node4" [label = " 0xf7fc4380|  |  |2"shape = "record"];"node5" [label = " (nil)| | |-1"shape = "record"];"node6" [label = " 0xf7fc4380|  |  |1"shape = "record"];"node7" [label = " 0xf7fc4380|  |  |2"shape = "record"];"node8" [label = " (nil)| | |-1"shape = "record"];"node9" [label = " (nil)| | |-1"shape = "record"];"node10" [label = " (nil)|  |  |-1"shape = "record"];"node11" [label = " (nil)|  |  |-1"shape = "record"];"node12" [label = " 0xf7fc43e0| | |1"shape = "record"];"node0":f0 -> "node1":f0 [id = 0];"node0":f1 -> "node2":f0 [id = 1];"node1":f0 -> "node3":f0 [id = 2];"node1":f1 -> "node4":f0 [id = 3];"node1":f2 -> "node5":f0 [id = 4];"node4":f0 -> "node3":f0 [id = 5];"node4":f1 -> "node6":f0 [id = 6];"node4":f2 -> "node10":f0 [id = 7];"node6":f0 -> "node3":f0 [id = 8];"node6":f1 -> "node7":f0 [id = 9];"node6":f2 -> "node9":f0 [id = 10];"node7":f0 -> "node3":f0 [id = 11];"node7":f1 -> "node1":f0 [id = 12];"node7":f2 -> "node8":f0 [id = 13];"node10":f1 -> "node11":f0 [id = 14];"node10":f2 -> "node12":f0 [id = 15];"node11":f2 -> "node1":f0 [id = 16];}
原创粉丝点击