Graphviz
1 Quick Start
digraph F { rankdir = LR; edge [style=solid]; node [style=filled, font=Courier]; subgraph M { rank = same; Start [label = "Lamp doesn't work" , shape = box, fillcolor = "#FF0000" ]; End [label = "Repair lamp" , shape = box, color = coral]; Con1 [label = "Lamp plugged in?" , shape = diamond, color = green, size = 3 ]; Con2 [label = "Bulb burned out?" , shape = diamond, color = green, size = 3 ]; } subgraph C { rank = same; RB [label = "Replace bulb" , shape = box, color = deepskyblue1]; AP [label = "Plug in lamp" , shape = box, color = deepskyblue1]; } Start -> Con1; Con1 -> AP [label = "No"]; Con1 -> Con2 [label = "Yes"]; Con2 -> RB [label = "Yes"]; Con2 -> End [label = "No"]; AP -> End RB -> End }
``$`graphviz digraph F { rankdir = LR; "node1" [ label = "{<f1> ADP |<f2> Pi }" shape = "record" ]; "node2" [ label = "<f0> ATP| <f1> Ca" shape = "record" ]; node2:f0 -> node1:f1 } ``$`
remove the “$” from code above
More exemples:
http://graphviz.org/gallery/
2 Parameters
2.1 Structure
Source:https://graphviz.gitlab.io/_pages/doc/info/lang.html
graph : [ strict ] (graph | digraph) [ ID ] '{' stmt_list '}' stmt_list : [ stmt [ ';' ] stmt_list ] 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 | _)
A -> {B C} is equivalent to A -> B A -> C
color for edge
Official Documentation
Source: http://graphviz.org/documentation/
Nodes,edges …
Souce: https://graphviz.gitlab.io/_pages/doc/info/attrs.html
Node shapes
Source: https://graphviz.gitlab.io/_pages/doc/info/shapes.html
Edge shapes
digraph F { rankdir ="LR" A -> B [arrowhead = "box" , color="green"] A -> C [arrowhead = "crow" , style = "dotted" ] A -> D [arrowhead = "dot" , weight = 10 ] A -> E [arrowhead = "diamond" , headport="s"] A -> F [arrowhead = "none" ] A -> G [arrowhead = "icurve" ] subgraph cluster_0{ B C D style=filled; color=lightgrey; node [style=filled,color=white]; label = "process #1" ; } }
Source: https://graphviz.gitlab.io/_pages/doc/info/arrows.html
Color
Source: https://graphviz.gitlab.io/_pages/doc/info/colors.html
Edge
headport / tailport
A -> n [headport = "n"]
headport = “n”,“ne”,“e”,“se”,“s”,“sw”,“w”,“nw”,“c”,“_”.
Style
A -> dashed [ style = "dashed"]
style = “dashed”, “dotted”, “solid”, “invis”, “bold”, “tapered”
Multi-color
a -> b [dir=both color="red:blue"]
c -> d [dir=none color="green:red;0.25:blue"]
Cluster
style =filled;color =lightgrey; node [style =filled,color=white]; label = "This is a cluster" ;
Model
For more
please visit:
使用graphviz绘制流程图(2015版)http://icodeit.org/2015/11/using-graphviz-drawing/