可視化graph的工具: GraphViz

這套工具可以把有向圖(digraph)和無向圖(graph)在平面內展現出來,方便觀察。GraphViz使用DOT(一種圖形描述語言)描述圖,然后有解釋工具dot生成圖像文件。dot支持多種圖像文件,包括非矢量的gif、矢量的ps、svg等約20多種格式。DOT語言也非常簡單易學。舉個例子:

digraph G {
?size = "4,4"
?main [shape=box];?/* this is a comment */
?main -> parse [weight=8];
?parse -> execute;
?main -> init [style=dotted];
?main -> cleanup;
?execute -> { make_string; printf}
?init -> make_string;
?edge [color=red]; // so is this
?main -> printf [style=bold, label="100 times"];
?node [shape=box, style=filled, color=".7.3 1.0"];
?execute -> compare;
}

存為test.dot,然后執行
? > dot test.dot -Tpng -o test.png
就生成了graph的圖像文件。很方便哦。
?
實際上GraphViz還可以畫出很多漂亮的“圖”。比如ER圖,hash table示意圖。更多請參考:http://www.graphviz.org/Gallery.php。以后可以考慮用GraphViz畫一些示意圖,既方便有專業,還很容易轉成ps(eps)。繼續研究研究。
?