graphviz 是贝尔实验室开发的一款开源绘图工具软件,使用
DSL(领域特定语言)dot语法作为脚本语言,通过布局引擎来解析此脚本,完成自动布局绘图
介绍
布局引擎(Layout Engines):
dot默认布局引擎(层次布局),主要用于有向图neato无向图布局,基于 spring 模型(force-based)算法fdp无向图布局,类似 neatosfdp适合大型无向图的多尺度布局twopi放射状(径向)布局circo环形布局
注:digraph 和 graph 是 DOT 语言中声明有向图和无向图的关键字,而不是布局引擎。
dot 语法说明:
->表示有向图中的边--表示无向图中的边
安装
apt install graphviz -y- 生成图片
dot digraph.dot -T png -o digraph.pngdigraph 有向图
digraph.dot
digraph demo{
a->b;
b->d;
c->d;
}graph 无向图
- graph.dot
graph demo1 {
a -- b
b -- c
c -- a
}负责的图
digraph action {
node [shape = record,height=.1];
node0 [label = "<head> head|<body> body|<foot> foot", height=.5]
node2 [shape = box label="mind"]
node0:head:n -> node2:n [label = "n"]
node0:head:ne -> node2:ne [label = "ne"]
node0:head:e -> node2:e [label = "e"]
node0:head:se -> node2:se [label = "se"]
node0:head:s -> node2:s [label = "s"]
node0:head:sw -> node2:sw [label = "sw"]
node0:head:w -> node2:w [label = "w"]
node0:head:nw -> node2:nw [label = "nw"]
node0:head:c -> node2:c [label = "c"]
node0:head:_ -> node2:_ [label = "_"]
node0:body[style=filled color=lightblue]
}扩展
- python 库
pip install pydotplus