官方文档
安装完graphviz后,文档在安装目录下,位置如下
E:\Gra2.38\share\graphviz\doc\html
中文乱码解决
将文件保存为utf-8编码
fontname="宋体";
dot语言语法
https://blog.csdn.net/jy692405180/article/details/52077979
https://blog.csdn.net/sd10086/article/details/52979462/
demo
有向图
digraph graph1{ //digraph-> graph--
label="this is a graph";
a[shape="box"];
b[shape="doublecircle"];
i[style="filled"];
ii[style="dotted",fontcolor="red"];
iii[style="solid"];
iiii[style="dashed"];
iiiii[style="bold"];
iiiiii[style="invis"];
aa[style="filled",fillcolor="green"];//The premise of using "fillcolor" is that "style" is "filled"
aaa[style="bold",color="blue"];
bb[width=,hight=];
edge \[style="dotted"\]; //node\[\] and edge\[\] are works for everything after that
a->i;
graph\[bgcolor="lightskyblue"\];
rankdir="TB"; //LR RL TB BT
//rotate=90;
subgraph cluster\_sgh{ //subgraph顧﹍uster
label="this is a subgraph";
bgcolor=yellow;
rankdir="LR";
c\[shape="egg",label="this is node c"\];
d\[label="this is node d"\];
}
subgraph cluster\_sgh2{
fontname="FangSong"; //鐎涙ぞ缍
label="input chinese";
bgcolor=blue;
e;f;
e->f;
}
subgraph cluster\_sgh3{
fontname="SimHei"; //姒涙垳缍
label="youkan input chinese";
bgcolor=red;
g;h;
h->h;
}
/*
table1 [label=<
1 | 2 |
3 | 4 |
];
*/
example [ shape = record, label = "{
cell1 | cell2 | cell3}" ];node [shape=record];
edge [style="bold"];
table1 [label="{
}
无向图
graph graph1{
label="this is a graph";
a;b;
a--b;
}
二叉树
digraph g {
node [shape="record", height=.];
node0[label="
node1[label="
node2[label="
node0:f0 -> node1:f1;
node0:f2 -> node2:f1;
}
二叉树2
digraph edge_settings {
A -> B [color = "black", label = 0];
B -> D [color = "black", label = 0];
A -> C [color = "black", label = 1];
B -> E [color = "black", label = 1];
C -> F [color = "black", label = 0];
C -> G [color = "black", label = 1];
D -> H \[color = "black", label = 0\];
D -> I \[color = "black", label = 1\];
E -> J \[color = "black", label = 0\];
E -> K \[color = "black", label = 1\];
F -> L \[color = "black", label = 0\];
F -> M \[color = "black", label = 1\];
G -> N \[color = "black", label = 0\];
G -> O \[color = "black", label = 1\];
}
横竖排
digraph g{
node[shape="record"];
a[label="{a|b|c}"]; //vertical column
b[label="
}
时序图
digraph g {
rankdir="LR";
{
rank="same";
a0 -> a1 -> a2;
}
{
rank="same";
b0 -> b1 -> b2;
}
a1 -> b1;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章