用Graphviz画图流程图得

4 篇文章 0 订阅
1 篇文章 0 订阅

Graphviz - Graph Visualization Software

官方示意图: Gallery
官方文档:Documentation

windows版本:

本地文档目录: C:\Program Files (x86)\Graphviz2.38\share\graphviz\doc\pdf 或 html

使用方法:C:\Program Files (x86)\Graphviz2.38\bin\ gvedit.exe, 双击运行即可

基本用法参考:

DOT语言:The DOT Language
命令行调用:Command-line Usage
输出格式:Output Formats
结点,边,图形属性:Node, Edge and Graph Attributes
结点形状关键词:Node Shapes
颜色关键词:Color Names
箭头关键词:Arrow Shapes

语法框架:

     graph  :  [ strict ] (graph | digraph) [ ID ] '{' stmt_list '}'   //一般用graph图,或digraph有向图
 stmt_list  :  [ stmt [ ';' ] stmt_list ]   //stmt有下列四中
      stmt  :  node_stmt
             | edge_stmt
             | attr_stmt
             | ID '=' ID
             | subgraph
 attr_stmt  :  (graph | node | edge) attr_list
 attr_list  :  '[' [ a_list ] ']' [ attr_list ]
    a_list  :  ID '=' ID [ (';' | ',') ] [ a_list ]
 edge_stmt  :  (node_id | subgraph) edgeRHS [ attr_list ]
   edgeRHS  :  edgeop (node_id | subgraph) [ edgeRHS ]
 node_stmt  :  node_id [ attr_list ]
   node_id  :  ID [ port ]
      port  :  ':' ID [ ':' compass_pt ]
             | ':' compass_pt
  subgraph  :  [ subgraph [ ID ] ] '{' stmt_list '}'
compass_pt  :  (n | ne | e | se | s | sw | w | nw | c | _)

如:
graph graph_name{
//stmt_list
}
digraph graph_name{
//stmt_list
}

例子:

tree

在这里插入图片描述

digraph tree {
	size="16,16";
	node [color=lightblue2, style=filled];
	"xx" -> "yy";
	"xx" -> "78";
	"yy" -> "zz";
	"yy" -> "12";
	"12" -> "34";
	"34" -> "12";  /*反向*/
	"34" -> "45";
	"78" -> "910";	
}

reference: Graphviz Example: UNIX Family ‘Tree’

流程图:
在这里插入图片描述

digraph flow {
    node [shape=ellipse, color=lightpink, style=filled];     
        "Start";
        "End";
        
    node [shape=box, color=lightpink, style=filled];     
        "Do Task";
        
    node [shape=diamond, color=lightpink, style=filled];     
        "Condition?";
        
    "start_point" [shape=diamond, label="", height=.01, width=.01] ;

    "Start" -> "start_point"   [dir=none,weight=2];
    "start_point" -> "Do Task" [dir=forward,weight=2] ;
    "Do Task" -> "Condition?" [dir=forward,weight=2] ;
    "Condition?" -> "start_point"  [label="Ture", dir=1, weight=0]
    "Condition?" -> "End"  [label="False"];
}

reference:
Graphviz Example: Entity-Relation Data Model 参考方块 椭圆
Graphviz Example: Cluster Gradients 参考子图
Graphviz Example: lion_share 参考结点

处理脚本

拷贝下列代码,保存为gen_photo.bat, 运行即可

set src_filename=ex1.gv
set photo_type=png
set out_filename=x

dot -Kcirco %src_filename% -T%photo_type% -o %out_filename%_circo.%photo_type%
dot -Kdot %src_filename% -T%photo_type% -o %out_filename%_dot.%photo_type%
dot -Kfdp %src_filename% -T%photo_type% -o %out_filename%_fdp.%photo_type%
dot -Kneato %src_filename% -T%photo_type% -o %out_filename%_neato.%photo_type%
dot -Knop %src_filename% -T%photo_type% -o %out_filename%_nop.%photo_type%
dot -Knop1 %src_filename% -T%photo_type% -o %out_filename%_nop1.%photo_type%
dot -Knop2 %src_filename% -T%photo_type% -o %out_filename%_nop2.%photo_type%
dot -Kosage %src_filename% -T%photo_type% -o %out_filename%_osage.%photo_type%
dot -Kpatchwork %src_filename% -T%photo_type% -o %out_filename%_patchwork.%photo_type%
dot -Ksfdp %src_filename% -T%photo_type% -o %out_filename%_sfdp.%photo_type%

参考:
Graphviz绘图 - DOT语言 - 老彭的博客
使用DOT语言和Graphviz绘图(翻译) - Casa Taloyum

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ha-Ha-Interesting

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值