-
HTML 标签
- 若左右排列(rankdir=LR)
k_1 [label="x(k-1)|w(k-1)"]
水平排列k_2 [label="{x(k-1)|w(k-1)}"]
垂直排列- table border=“0”,表格外框
- table cellborder=“1”,表格内框
digraph workflow{
rankdir=LR; bgcolor="transparent";
node [shape = record];
1 [label=<x<SUB>k-1</SUB>>];
1 -> 2 [label=<x<SUB>k-1</SUB>>];
k_1 [label="x(k-1)|w(k-1)"]
k_2 [label="{x(k-1)|w(k-1)}"]
k_4 [label="prev|{x(k-1)|w(k-1)}"]
node [shape = square,
color = black,]
k_3 [label=<
<table border="0" cellborder="1" cellspacing="0" align="center">
<tr>
<td>x<sub>k-3</sub></td><td>w<sub>k-3</sub></td>
</tr>
</table>
>];
}
- 子图 子图的命名一定是以cluster开始,如subgraph cluster_test{}
digraph traffic{
rankdir=TB; bgcolor="transparent";compound=true;//splines=line;
graph [nodesep=1]
size="8,12"
node [shape = box];
y[label="{yellow}"];
yr[label="{red,yellow}"];
empty[label="{ }"];
r[label="{red}"];
r_qf[label="{red}"];
yr_qf[label="{red,yellow}"];
node [style=invis];
subgraph cluster_q1 {
label="q1";
y:w -> y:w [label="¬r∧y"];
y -> yr [label="r∧y"];
yr -> y [label="¬r∧y"];
yr:w -> yr:w [label="r∧y"];
graph[style=line];
}
y -> empty [ltail=cluster_q1, label="¬r∧¬y", constraint=false]
yr -> r [ltail=cluster_q1, label="r∧¬y", constraint=false]
subgraph cluster_q0 {
label="q0";
empty:s -> empty:s [headlabel="¬r∧¬y"];
empty -> r [color=transparent];
r:ne -> empty:se [label="¬r∧¬y"];
graph[style=line];
}
empty:n -> y [ltail=cluster_q0, label="¬r∧y", constraint=false]
//r:sw -> yr [ltail=cluster_q0, label="r∧y", constraint=false]
r -> start [dir=back, ltail=cluster_q0]
subgraph cluster_qf {
label="qF/q2";
yr_qf -> r_qf [color=transparent];
//s1 -> r_qf [color=transparent];
graph[style=line];
}
empty -> yr_qf [ltail=cluster_q0, label="r∧y", constraint=false]
r_qf -> r [dir=back, lhead=cluster_q0, taillabel="r∧¬y", constraint=false]
}
1. 嵌套html标签
digraph workflow{
rankdir=TB; bgcolor="transparent";
graph [nodesep="0.5", ranksep="0.2"]
node [shape=box]
subgraph cluster_kn{
label = <<font color="red">loop through </font> all <x,w> pairs>
node [shape = box];
V_N [label="V(N,x,w)←J(x,w)"];
}
subgraph cluster_kother{
label = <<font color="red">loop through </font> all <x,w> pairs>
node [shape = box];
Vpi_init [label="V(<x,w>)←+inf\n pi(<x,w>)←0"];
Vpi [label="V(<x,y>)←min(V(<x,y>), g+E)\n pi(<x,w>)←argmin(V(<x,y>), g+E)"];
subgraph cluster_u{
label = <<font color="red">loop through </font> all u>
node [shape = box]
g [label="g←g(x,w,u)"];
E_init [label="E←0"];
subgraph cluster_min{
label = <<font color="red">loop through </font> all subsequent <x',w'> pairs>
node [shape = box]
E_sum [label="E(x,w,u)=sum(P*V):\n E ← E + P(<x',w'>|<x,w>,u)V(<x',w'>)"]
}
}
}
node [shape = box];
init[label="Init all V(s)←0"];
node [shape = diamond];
k_N [label="k=N"];
node [shape = box, style="rounded"];
start[label="start: backward induction"];
end[label="end"];
start -> init;
init -> k_N;
k_N:w -> V_N:n [label="Y"];
V_N:w -> V_N:w;
k_N:e -> Vpi_init:n [label="N"];
Vpi_init -> g;
g -> E_init;
E_init -> E_sum;
E_sum:e -> E_sum:e;
E_sum -> Vpi;
E_sum:e -> g:e [constraint=false];
Vpi:e -> g:e [constraint=false];
V_N:s -> end:n;
Vpi:s -> end:n;
}