基本
- 字符串 都要加双引号, 可以加
\n
换行符 - 注释 双斜杠
//
或/* */
- 有向图
digraph
, 节点关系: 指向->
- 无向图
graph
, 节点关系: 连通--
- 属性
node[attribute1=value1, attribute2=value2]
- 大小: size=”2,2”; 单位为英寸
- 标签: label=”显示在图上的内容”
- 边:edge [color=red,style=dotted]; 这句话之后生效
- 节点:node [color=navy]; 这句话之后生效
- 边方向:rankdir=参数值;LR(从左到右),RL,BT,TB
- 节点形状: a[shape=box]; 默认是椭圆
- 边框大小:a[width=.1,height=2.5]; 单位为英寸
- 边框颜色:a[color=red];
链接
- 节点形状
- 箭头形状
- 颜色配置
示例
普通绘图
1 2 3 4 5 |
digraph G { a -> b [color=red]; a [label="aet"]; b [label="lif"]; }; |
1 2 3 4 5 |
digraph G { A -> B; A -> C -> B; A -> D -> B; } |
节点形状
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
digraph G { size = "4, 4"; main [shape=box]; /* 这是注释 */ main -> parse [weight=8]; parse -> execute; main -> init [style=dotted]; main -> cleanup; execute -> { make_string; printf} init -> make_string; edge [color=red]; // 设置生效 main -> printf [style=bold,label="100 times"]; make_string [label="make a\n字符串"]; node [shape=box,style=filled,color=".7 .3 1.0"]; execute -> compare; } |
1 2 3 4 5 6 7 8 |
digraph G { a -> b -> c; b -> d; a [shape=polygon,sides=5,peripheries=3,color=lightblue,style=filled]; c [shape=polygon,sides=4,skew=.4,label="hello world"] d [shape=invtriangle]; e [shape=polygon,sides=4,distortion=.7]; } |
树形结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
digraph g { node [shape = record,height=.1]; node0[label = "<f0> |<f1> G|<f2> "]; node1[label = "<f0> |<f1> E|<f2> "]; node2[label = "<f0> |<f1> B|<f2> "]; node3[label = "<f0> |<f1> F|<f2> "]; node4[label = "<f0> |<f1> R|<f2> "]; node5[label = "<f0> |<f1> H|<f2> "]; node6[label = "<f0> |<f1> Y|<f2> "]; node7[label = "<f0> |<f1> A|<f2> "]; node8[label = "<f0> |<f1> C|<f2> "]; "node0":f2 -> "node4":f1; "node0":f0 -> "node1":f1; "node1":f0 -> "node2":f1; "node1":f2 -> "node3":f1; "node2":f2 -> "node8":f1; "node2":f0 -> "node7":f1; "node4":f2 -> "node6":f1; "node4":f0 -> "node5":f1; } |
有向图
1 2 3 4 5 6 7 8 9 10 11 12 |
digraph g { //edge[style=dashed]; //定义边的样式, 虚线 node[peripheries=2, style=filled, color="#eecc80"]; a->b [color=red, style=dashed]; //定义边的颜色, 红色 (b和方括号之间必须有空格) b->c; //箭头, 三角形; 箭尾, 菱形 b->d [arrowhead=box]; //箭头, 长方形 b->e [dir=none]; //没有箭头 d->f [dir=both]; //双向箭头 f->h [label=go]; //定义edge的标签 f->k [arrowhead=diamond]; //更改箭头形状 k->y [headlabel="哈哈", taillabel="洗洗"]; } |
无向图
1 2 3 4 |
graph g { edge[style=dashed]; //定义边的样式, 虚线 a -- b [color=red]; //定义边的颜色, 红色 (b和方括号之间必须有空格) } |
本文为原创文章,版权归Aet所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ 【Nowcoder-May】05/09
- ♥ Reading 2021 《百年孤独》10/04
- ♥ CMake教程二07/07
- ♥ 大话数据结构_图相关02/17
- ♥ 2023_02_2202/27
- ♥ Windbg:命令总览学习一04/06