关键字:Graphviz Windows环境安装、配置环境变量、pcharm中调用、中文乱码、dot语句基本格式
Graphviz Windows环境安装:html
1.官网下载
node
官网下载地址
python

2.建立桌面快捷方式:
git
安装目录\bin文件夹\:找到gvedit.exe文件右键 发送到桌面快捷方式,以下图:
windows
将graphviz安装目录下的bin文件夹添加到Path环境变量中:
进入windows命令行界面,输入dot -version
,而后按回车,若是显示graphviz的相关版本信息,则安装配置成功。如图:
# coding:utf-8
from graphviz import Digraph
dot = Digraph(comment='The Round Table')
# 添加圆点 A, A的标签是 King Arthur
dot.node('A', 'king')
dot.view() #后面这句就注释了,也能够使用这个命令查看效果
# 添加圆点 B, B的标签是 Sir Bedevere the Wise
dot.node('B', 'Sir Bedevere the Wise')
#dot.view()
# 添加圆点 L, L的标签是 Sir Lancelot the Brave
dot.node('L', 'Sir Lancelot the Brave')
#dot.view()
#建立一堆边,即链接AB的边,链接AL的边。
dot.edges(['AB', 'AL'])
#dot.view()
# 在建立两圆点之间建立一条边
dot.edge('B', 'L', constraint='false')
#dot.view()
# 获取DOT source源码的字符串形式
print(dot.source)
# 保存source到文件,并提供Graphviz引擎
dot.render('test-output/round-table.gv', view=True)
将对应标签放在英文双引号内
- dot input.dot -T png -o output.txt
cmd:
- 有向图:diagraph申明,结点关系为"->",能够//注释
- 无向图:graph 申明 结点关系"--"
- 子图 :subgraph声明 父图是无向图他自己也得是无向图 父图是有向图自己也得是有向图
digraph G{
{ a b c} -> { d e f }
}