graphviz的使用

偶尔善良 提交于 2020-04-07 03:57:02

graphviz(Graph Visualization Software)是linux上著名的开源绘图软件。它的最大特点是可以使用简洁的代码绘图。

对于审美有问题的同学们(比如我),这是一个福音。

 

1.安装(此处略)

2.使用示例如下:[来源引用]

D:\>dot -T jpg tes.dot -o test.jpg
<cmd>介绍
dot 渲染的图具有明确方向性。
neato 渲染的图缺乏方向性。
twopi 渲染的图采用放射性布局。
circo 渲染的图采用环型布局。
fdp 渲染的图缺乏方向性。
sfdp 渲染大型的图,图片缺乏方向性。

来自官网:

dot - "hierarchical" or layered drawings of directed graphs. This is the default tool to use if edges have directionality.

neato - "spring model'' layouts.  This is the default tool to use if the graph is not too large (about 100 nodes) and you don't know anything else about it. Neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling.

fdp - "spring model'' layouts similar to those of neato, but does this by reducing forces rather than working with energy.

sfdp - multiscale version of fdp for the layout of large graphs.

twopi - radial layouts, after Graham Wills 97. Nodes are placed on concentric circles depending their distance from a given root node.

circo - circular layout, after Six and Tollis 99, Kauffman and Wiese 02. This is suitable for certain diagrams of multiple cyclic structures, such as certain telecommunications networks.

3.代码风格示例:

  A -> {B C} is equivalent to
  A -> B
  A -> C


subgraph { 
rank = same; A; B; C; 
} 
This (anonymous) subgraph specifies that the nodes A, B and C should all be placed on the same rank if drawn using dot.


strict graph { 
  a -- b
  a -- b
  b -- a [color=blue]
} 
will have a single edge connecting nodes a and b, whose color is blue.
digraph graph1{
  上学 -> 吃饭
  上学 -> 完成作业
  上学 -> 放学
   放学 -> 回家
}

4.结果示例

5.后记

这里还有一篇外国人写的graphviz高阶用法,供大家拓展用。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!