Example.1
digraph base_flow {
// 步骤1: 定义digraph的属性
label = <<B>graphviz使用流程</B>>;
// 步骤2: 定义node、edge的属性
node[shape=box];
// 步骤3: 添加node、edge
graph_attr -> node_edge_attr -> node_edge_added -> custom_attr;
// 步骤4: 定义特定node,edge的属性
graph_attr[label="1. 定义digraph的属性"];
node_edge_attr[label="2. 定义node、edge的属性"];
node_edge_added[label="3. 添加node、edge"];
custom_attr[label="4. 定义特定node,edge的属性"];
}
Example.2
digraph finite_state_machine {
rankdir=LR;
node[fixedsize = true,shape = doublecircle,width=1.2,color =green];
IDLE
IDLE->IDLE;
edge[];
subgraph a{
node[fixedsize = true,shape = doublecircle,width=1.2,color =red];
START_W
SEND_CTRL_BYTE_W[label = "SND_CB_W"]
RECEIVE_ACK_1_W[label = "RSV_AK1_W"]
RECEIVE_ACK_2_W[label = "RSV_AK2_W"]
RECEIVE_ACK_3_W[label = "RSV_AK3_W"]
SEND_ADDR_BYTE_W[label="SND_ADD_W"]
SEND_DATA_BYTE_W[label="SND_DAT_W"]
STOP_W
IDLE->START_W[label=""];
START_W->SEND_CTRL_BYTE_W[label=""];
START_W->START_W;
SEND_CTRL_BYTE_W->RECEIVE_ACK_1_W;
SEND_CTRL_BYTE_W->SEND_CTRL_BYTE_W;
RECEIVE_ACK_1_W->RECEIVE_ACK_1_W;
RECEIVE_ACK_1_W->SEND_ADDR_BYTE_W;
SEND_ADDR_BYTE_W->SEND_ADDR_BYTE_W;
SEND_ADDR_BYTE_W->RECEIVE_ACK_2_W;
RECEIVE_ACK_2_W->RECEIVE_ACK_2_W;
RECEIVE_ACK_2_W->SEND_DATA_BYTE_W;
SEND_DATA_BYTE_W->SEND_DATA_BYTE_W;
SEND_DATA_BYTE_W->RECEIVE_ACK_3_W;
RECEIVE_ACK_3_W->RECEIVE_ACK_3_W;
RECEIVE_ACK_3_W->STOP_W;
STOP_W:n->IDLE:ne;
}
//********************************************
//Receive
//********************************************
subgraph b{
node[fixedsize = true,shape = doublecircle,width=1.2,color =blue];
START_R_1;
SEND_CTRL_BYTE_1_R[label = "SND_CB1_R"]
SEND_CTRL_BYTE_2_R[label = "SND_CB2_R"]
RECEIVE_ACK_1_R[label = "RSV_AK1_R"]
RECEIVE_ACK_2_R[label = "RSV_AK2_R"]
RECEIVE_ACK_3_R[label = "RSV_AK3_R"]
SEND_ADDR_BYTE_R[label="SND_ADD_R"]
RECEIVE_DATA_R[label="RSV_DAT_R"]
START_R_2
IDLE->START_R_1[label=""];
START_R_1->START_R_1;
START_R_1->SEND_CTRL_BYTE_1_R;
SEND_CTRL_BYTE_1_R->SEND_CTRL_BYTE_1_R;
SEND_CTRL_BYTE_1_R->RECEIVE_ACK_1_R;
RECEIVE_ACK_1_R->RECEIVE_ACK_1_R;
RECEIVE_ACK_1_R->SEND_ADDR_BYTE_R;
SEND_ADDR_BYTE_R->SEND_ADDR_BYTE_R;
SEND_ADDR_BYTE_R->RECEIVE_ACK_2_R
RECEIVE_ACK_2_R->RECEIVE_ACK_2_R
RECEIVE_ACK_2_R->START_R_2
START_R_2->START_R_2
START_R_2->SEND_CTRL_BYTE_2_R
SEND_CTRL_BYTE_2_R->SEND_CTRL_BYTE_2_R
SEND_CTRL_BYTE_2_R->RECEIVE_ACK_3_R
RECEIVE_ACK_3_R->RECEIVE_ACK_3_R
RECEIVE_ACK_3_R->RECEIVE_DATA_R
RECEIVE_DATA_R->RECEIVE_DATA_R
RECEIVE_DATA_R->STOP_R
STOP_R:s->IDLE:se
}
//********************************************
//
//********************************************
}
Example.3
digraph show {
// node
//rankdir = LR;
node[shape="box" , fontname="DFKai-SB" fontsize=16 size="5,5" color="gray" distortion=.7]
edge[ fontname="DFKai-SB" fontsize=15 fontcolor="black" color="brown" style="filled"]
儒家[shape="egg"]
道家[shape="egg"]
法家[shape="egg"]
墨家[shape="egg"]
救世[shape="doubleoctagon"]
中庸[shape="Mdiamond"]
百家争鸣->儒家->克己复礼
百家争鸣->墨家->兼爱非攻
百家争鸣->法家
法家->"不别亲疏,不殊贵贱,一断于法"
百家争鸣->道家
儒家->孔子->孟子->荀子
墨家->墨子
墨家->为天下谋
儒家->仁爱
道家->杨朱->老子->庄子
老子->善利万物而不争->示弱
老子->无政府主义
庄子->无政府主义
庄子->己所不欲勿施于人->自由
庄子->己所甚欲勿施于人->自由
自由->逍遥游
庄子->人生观->关你何事
人生观->关我何事
庄子->做人开心最重要->TVB
杨朱->一毛不拔
杨朱->且趣当生奚遑死后
法家->韩非
法家->两面三刀->奖惩
两面三刀->势
两面三刀->术
两面三刀->法
孔子->中庸
孔子->礼乐
孔子->鬼神[label="敬鬼神而远之"]
孔子->天命->使命
孟子->义
孟子->浩然大丈夫
孟子->民权
荀子->天道人性
荀子->君子自强
法家->君权
儒家->救世[arrowhead="vee" color ="steelblue"]
墨家->救世[arrowhead="vee" color ="steelblue"]
法家->救世[arrowhead="vee" color ="steelblue"]
墨家->鬼神
墨家->义士
道家->儒家[arrowhead="vee" color ="gold" label="天下大骇儒墨皆起"]
道家->孔子[arrowhead="vee" color ="gold" label="圣人不死大盗不止"]
道家->墨家[arrowhead="vee" color ="gold" ]
道家->不爱
道家->先存诸己而后存诸人
法家->仁爱[arrowhead="vee" color ="gold" label="这玩意没用"]
法家->礼乐[arrowhead="vee" color ="gold" label="这玩意没用"]
法家->兼爱非攻[arrowhead="vee" color ="gold" label="这玩意没用"]
仁爱->兼爱非攻[arrowhead="vee" color ="gold" dir="both"]
仁爱->不爱[arrowhead="vee" color ="gold" dir="both"]
}
Example.4
graph G77 {
node [fontsize="8"];
run -- intr;
intr -- runbl;
runbl -- run;
run -- kernel;
kernel -- zombie;
kernel -- sleep;
kernel -- runmem;
sleep -- swap;
swap -- runswap;
runswap -- new;
runswap -- runmem;
new -- runmem;
sleep -- runmem;
}
Example.5
digraph asde91 {
ranksep=.75; size = "7.5,7.5";
{
node [shape=plaintext, fontsize=16];
/* the time-line graph */
past -> 1978 -> 1980 -> 1982 -> 1983 -> 1985 -> 1986 ->
1987 -> 1988 -> 1989 -> 1990 -> "future";
/* ancestor programs */
"Bourne sh"; "make"; "SCCS"; "yacc"; "cron"; "Reiser cpp";
"Cshell"; "emacs"; "build"; "vi"; "<curses>"; "RCS"; "C*";
}
{ rank = same;
"Software IS"; "Configuration Mgt"; "Architecture & Libraries";
"Process";
};
node [shape=box];
{ rank = same; "past"; "SCCS"; "make"; "Bourne sh"; "yacc"; "cron"; }
{ rank = same; 1978; "Reiser cpp"; "Cshell"; }
{ rank = same; 1980; "build"; "emacs"; "vi"; }
{ rank = same; 1982; "RCS"; "<curses>"; "IMX"; "SYNED"; }
{ rank = same; 1983; "ksh"; "IFS"; "TTU"; }
{ rank = same; 1985; "nmake"; "Peggy"; }
{ rank = same; 1986; "C*"; "ncpp"; "ksh-i"; "<curses-i>"; "PG2"; }
{ rank = same; 1987; "Ansi cpp"; "nmake 2.0"; "3D File System"; "fdelta";
"DAG"; "CSAS";}
{ rank = same; 1988; "CIA"; "SBCS"; "ksh-88"; "PEGASUS/PML"; "PAX";
"backtalk"; }
{ rank = same; 1989; "CIA++"; "APP"; "SHIP"; "DataShare"; "ryacc";
"Mosaic"; }
{ rank = same; 1990; "libft"; "CoShell"; "DIA"; "IFS-i"; "kyacc"; "sfio";
"yeast"; "ML-X"; "DOT"; }
{ rank = same; "future"; "Adv. Software Technology"; }
"PEGASUS/PML" -> "ML-X";
"SCCS" -> "nmake";
"SCCS" -> "3D File System";
"SCCS" -> "RCS";
"make" -> "nmake";
"make" -> "build";
}
Example.6
digraph ORG {
ranksep=0.2;
node[shape=box3d width=2.3 height=0.6 fontname="Arial"];
CEO [ label = "Important CEO" ]
CFO [ label = "Less important CFO" ]
HR [ label = "Human Resources" ]
CxO [ label = "An unknown CxO" ]
staff_1 [ label = "Staff 1"]
staff_2 [ label = "Staff 2"]
staff_3 [ label = "Staff 3"]
staff_4 [ label = "Staff 4"]
node[shape=none, width=0, height=0, label=""];
edge[dir=none];
CEO -> hierarchy_1 -> hierarchy_2 -> hierarchy_3;
{rank=same; CFO -> hierarchy_1 -> HR;}
{rank=same; CxO -> hierarchy_2;}
{rank=same; staff_1 -> staff_2 -> hierarchy_4 -> staff_3 -> staff_4 }
hierarchy_3 -> hierarchy_4
}
Example.7
digraph G {
/ start Heroku styles
graph [fontname="helvetica",fontsize=14,splines=true,pad=0.1,compound=true,color="grey60",fontcolor="grey10",fillcolor=grey95,style="filled"];
node [fontname="helvetica",fontsize=12,color=purple4,shape=box,style="rounded, filled",fontcolor=purple4,fillcolor=grey99,penwidth=2];
edge [fontname="helvetica",color=grey35,fontcolor=black,arrowhead="normal",penwidth=2,arrowsize=0.5];
/ end Heroku styles
subgraph cluster3 {
label="Common Runtime"
"App C"
}
subgraph cluster1 {
label="Private Space A"
"App A"
"Postgres Instance\n(Private or Shield Plan)"
}
subgraph cluster2 {
label="Private Space B"
"App B"
}
"App A" -> "Postgres Instance\n(Private or Shield Plan)" [color=chartreuse3]
"App B":s -> "Postgres Instance\n(Private or Shield Plan)":e [color=red, style=dashed, dir=none]
"App C":s -> "Postgres Instance\n(Private or Shield Plan)":w [color=red, style=dashed, dir=none]
}
Example.8
digraph G {
/ start Heroku styles
graph [fontname="helvetica",fontsize=14,splines=true,pad=0.1,compound=true,color="grey60",fontcolor="grey10",fillcolor=grey95,style="filled"];
node [fontname="helvetica",fontsize=12,color=purple4,shape=box,style="rounded, filled",fontcolor=purple4,fillcolor=grey99,penwidth=2];
edge [fontname="helvetica",color=grey35,fontcolor=black,arrowhead="normal",penwidth=2,arrowsize=0.5];
/ end Heroku styles
subgraph cluster3 {
label="Common Runtime"
"App C"
}
subgraph cluster1 {
label="Private Space A"
"App A"
"Postgres Instance\n(Private or Shield Plan)"
}
subgraph cluster2 {
label="Private Space B"
"App B"
}
"App A" -> "Postgres Instance\n(Private or Shield Plan)" [color=chartreuse3]
"App B":s -> "Postgres Instance\n(Private or Shield Plan)":ne [color=red, style=dashed, dir=none]
"App C":s -> "Postgres Instance\n(Private or Shield Plan)":nw [color=red, style=dashed, dir=none]
}
Example.9
digraph G {
App [
shape=record
label="{App|id\nname}"
]
User [
shape=record
label="{User|id\nname\nemail}"
]
User [shape=record]
App -> User [arrowhead=crow, arrowtail=crow, dir=both]
}
Example.10
digraph D {
node [shape=plaintext fontname="Sans serif" fontsize="8"];
task_menu [ label=<
<table border="1" cellborder="0" cellspacing="1">
<tr><td align="left"><b>Task 1</b></td></tr>
<tr><td align="left">Choose Menu</td></tr>
<tr><td align="left"><font color="darkgreen">done</font></td></tr>
</table>>];
task_ingredients [ label=<
<table border="1" cellborder="0" cellspacing="1">
<tr><td align="left"><b>Task 2</b></td></tr>
<tr><td align="left">Buy ingredients</td></tr>
<tr><td align="left"><font color="darkgreen">done</font></td></tr>
</table>>];
task_invitation [ label=<
<table border="1" cellborder="0" cellspacing="1">
<tr><td align="left"><b>Task 4</b></td></tr>
<tr><td align="left">Send invitation</td></tr>
<tr><td align="left"><font color="darkgreen">done</font></td></tr>
</table>>];
task_cook [ label=<
<table border="1" cellborder="0" cellspacing="1">
<tr><td align="left"><b>Task 5</b></td></tr>
<tr><td align="left">Cook</td></tr>
<tr><td align="left"><font color="red">todo</font></td></tr>
</table>>];
task_table[ label=<
<table border="1" cellborder="0" cellspacing="1">
<tr><td align="left"><b>Task 3</b></td></tr>
<tr><td align="left">Lay table</td></tr>
<tr><td align="left"><font color="red">todo</font></td></tr>
</table>>];
task_eat[ label=<
<table border="1" cellborder="0" cellspacing="1">
<tr><td align="left"><b>Task 6</b></td></tr>
<tr><td align="left">Eat</td></tr>
<tr><td align="left"><font color="red">todo</font></td></tr>
</table>>];
task_menu -> task_ingredients;
task_ingredients -> task_cook;
task_invitation -> task_cook;
task_table -> task_eat;
task_cook -> task_eat;
}
Example.11
digraph H {
parent [
shape=plaintext
label=<
<table border='1' cellborder='1'>
<tr><td colspan="3">The foo, the bar and the baz</td></tr>
<tr><td port='port_one'>First port</td><td port='port_two'>Second port</td><td port='port_three'>Third port</td></tr>
</table>
>];
child_one [
shape=plaintext
label=<
<table border='1' cellborder='0'>
<tr><td>1</td></tr>
</table>
>];
child_two [
shape=plaintext
label=<
<table border='1' cellborder='0'>
<tr><td>2</td></tr>
</table>
>];
child_three [
shape=plaintext
label=<
<table border='1' cellborder='0'>
<tr><td>3</td></tr>
</table>
>];
parent:port_one -> child_one;
parent:port_two -> child_two;
parent:port_three -> child_three;
}
Example.12
digraph H {
aHtmlTable [
shape=plaintext
label=<
<table border='1' cellborder='0' style='rounded'>
<tr><td>col 1</td><td>foo</td></tr>
<tr><td>COL 2</td><td>bar</td></tr>
</table>
>];
}
Example.13
digraph D {
node [shape=plaintext]
some_node [
label=<
<table border="0" cellborder="1" cellspacing="0">
<tr><td bgcolor="yellow">Foo</td></tr>
<tr><td bgcolor="lightblue"><font color="#0000ff">Bar</font></td></tr>
<tr><td bgcolor="#f0e3ff"><font color="#ff1020">Baz</font></td></tr>
</table>>
];
}
Example.14
digraph {
tbl [
shape=plaintext
label=<
<table border='0' cellborder='1' color='blue' cellspacing='0'>
<tr><td>foo</td><td>bar</td><td>baz</td></tr>
<tr><td cellpadding='4'>
<table color='orange' cellspacing='0'>
<tr><td>one </td><td>two </td><td>three</td></tr>
<tr><td>four </td><td>five </td><td>six </td></tr>
<tr><td>seven</td><td>eight</td><td>nine </td></tr>
</table>
</td>
<td colspan='2' rowspan='2'>
<table color='pink' border='0' cellborder='1' cellpadding='10' cellspacing='0'>
<tr><td>eins</td><td>zwei</td><td rowspan='2'>drei<br/>sechs</td></tr>
<tr><td>vier</td><td>fünf</td> </tr>
</table>
</td>
</tr>
<tr><td>abc</td></tr>
</table>
>];
}
Example.15
digraph H {
aHtmlTable [
shape=plaintext
color=blue // The color of the border of the table
label=<
<table border='1' cellborder='0'>
<tr><td>col 1</td><td>foo</td></tr>
<tr><td>COL 2</td><td>bar</td></tr>
</table>
>];
}
Example.16
digraph D {
subgraph cluster_p {
label = "Parent";
subgraph cluster_c1 {
label = "Child one";
a;
subgraph cluster_gc_1 {
label = "Grand-Child one";
b;
}
subgraph cluster_gc_2 {
label = "Grand-Child two";
c;
d;
}
}
subgraph cluster_c2 {
label = "Child two";
e;
}
}
}
Example.17
digraph D {
label = <The <font color='red'><b>foo</b></font>,<br/> the <font point-size='20'>bar</font> and<br/> the <i>baz</i>>;
labelloc = "t"; // place the label at the top (b seems to be default)
node [shape=plaintext]
FOO -> {BAR, BAZ};
}
Example.18
digraph D {
label = "The foo, the bar and the baz";
labelloc = "t"; // place the label at the top (b seems to be default)
node [shape=plaintext]
FOO -> {BAR, BAZ};
}
Example.19
digraph L {
node [shape=record fontname=Arial];
a [label="one\ltwo three\lfour five six seven\l"]
b [label="one\ntwo three\nfour five six seven"]
c [label="one\rtwo three\rfour five six seven\r"]
a -> b -> c
}
Example.20
digraph D {
A -> {B, C, D} -> {F}
}
Example.21
digraph D {
node [fontname="Arial"];
node_A [shape=record label="shape=record|{above|middle|below}|right"];
node_B [shape=plaintext label="shape=plaintext|{curly|braces and|bars without}|effect"];
}
Example.22
digraph D {
A [shape=diamond]
B [shape=box]
C [shape=circle]
A -> B [style=dashed, color=grey]
A -> C [color="black:invis:black"]
A -> D [penwidth=5, arrowhead=none]
}
Example.23
graph {
rankdir=LR;
a -- { b c d }; b -- { c e }; c -- { e f }; d -- { f g }; e -- h;
f -- { h i j g }; g -- k; h -- { o l }; i -- { l m j }; j -- { m n k };
k -- { n r }; l -- { o m }; m -- { o p n }; n -- { q r };
o -- { s p }; p -- { s t q }; q -- { t r }; r -- t; s -- z; t -- z;
{ rank=same; b, c, d }
{ rank=same; e, f, g }
{ rank=same; h, i, j, k }
{ rank=same; l, m, n }
{ rank=same; o, p, q, r }
{ rank=same; s, t }
}
Example.24
graph {
rankdir=LR; // Left to Right, instead of Top to Bottom
a -- { b c d };
b -- { c e };
c -- { e f };
d -- { f g };
e -- h;
f -- { h i j g };
g -- k;
h -- { o l };
i -- { l m j };
j -- { m n k };
k -- { n r };
l -- { o m };
m -- { o p n };
n -- { q r };
o -- { s p };
p -- { s t q };
q -- { t r };
r -- t;
s -- z;
t -- z;
}
Example.25
digraph {
subgraph cluster_0 {
label="Subgraph A";
a -> b;
b -> c;
c -> d;
}
subgraph cluster_1 {
label="Subgraph B";
a -> f;
f -> c;
}
}
Example.26
graph {
a -- b[color=red,penwidth=3.0];
b -- c;
c -- d[color=red,penwidth=3.0];
d -- e;
e -- f;
a -- d;
b -- d[color=red,penwidth=3.0];
c -- f[color=red,penwidth=3.0];
}
digraph {
a -> b[label="0.2",weight="0.2"];
a -> c[label="0.4",weight="0.4"];
c -> b[label="0.6",weight="0.6"];
c -> e[label="0.6",weight="0.6"];
e -> e[label="0.1",weight="0.1"];
e -> b[label="0.7",weight="0.7"];
}
Example.27
digraph {
compound=true;
node [ fontname="Handlee" ];
subgraph cluster_website {
label="*Website*";
subgraph cluster_frontend {
label="*Frontend*";
React;
Bootstrap;
}
subgraph cluster_backend {
label="*Backend*";
expressjs;
"aws-sdk";
}
}
subgraph cluster_aws {
label="*AWS*";
DynamoDb;
S3;
}
React -> expressjs;
expressjs -> "aws-sdk" [constraint=false];
"aws-sdk" -> S3 [lhead=cluster_aws];
}
Example.28
digraph {
node [ fontname="Handlee" ];
subgraph cluster_website {
label="*Website*";
subgraph cluster_frontend {
label="*Frontend*";
React;
Bootstrap;
}
subgraph cluster_backend {
label="*Backend*";
expressjs;
"aws-sdk";
}
}
subgraph cluster_aws {
label="*AWS*";
DynamoDb;
S3;
}
React -> expressjs;
expressjs -> "aws-sdk" [constraint=false];
"aws-sdk" -> S3;
"aws-sdk" -> DynamoDb;
}
Example.29
digraph {
node [ fontname="Handlee" ];
subgraph cluster_frontend {
label="*Frontend*";
React;
Bootstrap;
}
subgraph cluster_backend {
label="*Backend*";
expressjs;
"aws-sdk";
}
React -> expressjs;
expressjs -> "aws-sdk";
}
Example.30
digraph {
rankdir=LR;
node [ shape=record ];
struct1 [
label = "a|b|<port1>c";
];
struct2 [
label = "a|{<port2>b1|b2}|c";
];
struct1:port1 -> struct2:port2 [ label="xyz" ];
}
Example.31
digraph {
node [ shape=square ];
edge [ style=dashed ];
see -> think -> do;
}
Example.32
digraph {
Tinos [ fontname="Tinos" ];
Handlee [ fontname="Handlee" ];
"Sedgwick Ave" [ fontname="Sedgwick Ave" ];
"*also Sedgwick*";
}
Example.33
digraph {
rankdir=LR;
hello [ label = "Hello" ];
hello -> world [ color="orange", penwidth=3.0 ];
}
Example.34
graph hmc_graph{
"hmc01" -- "test520"
"test520" -- "lpar2"
"test520" -- "lpar3"
"hmc01" -- "test570"
"test570" -- "aixtest01"
"test570" -- "aixtest02"
"test570" -- "aixtest03"
"hmc01" -- "test510"
"test510" -- "lpar1"
}
Example.35
digraph example3
{
Server1 -> Server2
Server2 -> Server3
Server3 -> Server1
Server1 [shape=box, label="Server1\nWeb Server", fillcolor="#ABACBA", style=filled]
Server2 [shape=triangle, label="Server2\nApp Server", fillcolor="#DDBCBC", style=filled]
Server3 [shape=circle, label="Server3\nDatabase Server", fillcolor="#FFAA22",style=filled]
}
Example.36
digraph pipleline {
rankdir=LR;
g [label="Gitlab"];
j [label="Jenkins"];
t [label="Testing"];
p [label="Production" color=red];
g -> j [label="Trigger"];
j -> t [label="Build"];
t -> p [label="Approved"];
}
Example.37
digraph graphname{
a -> {b c};
c -> e;
b -> d;
subgraph cluster_bc {
bgcolor=red;
b;
c;
}
subgraph cluster_de {
label="Block"
d;
e;
}
}
Example.38
strict graph {
// 设置节点属性
b [shape=box];
c [shape=triangle];
// 设置边属性
a -- b [color=blue];
a -- c [style=dotted];
}
Example.39
graph graphname {
a -- b -- c;
b -- d;
}
Example.40
digraph graphname2 {
a -> b -> c;
b -> d;
}