概述

Graphviz (Graph Visualization Software) 是一个由AT&T实验室启动的开源工具包。DOT是一种图形描述语言,非常简单的,

Graphviz就是用来处理这种语言的工具。只需要简单了解一下DOT语言,就可以用Graphviz绘图了,它对程序员特别有用。

So in short, if you are a programmer, it is born for you。

无向图

graph graphname {

a -- b -- c;

b -- d;

}

有向图

digraph graphname {

a -> b -> c;

b -> d;

}

属性

//DOT语言中,可以对节点和边添加不同的属性。

digraph graphname {

//节点的属性,节点的名称

a [lable = "Foo"];

//节点的属性,节点的形状

b [shape = box];

//边的属性,边的颜色

a -> b -> c [color = blue];

//边的属性,边的线状

b -> d [style = dotted];

}

基本图形

digraph G {

//把图片的尺寸设为4inch * 4inch

size = "4,4";

main [shape = box];

//边的重要程度,默认是1

main->parse [weight = 8];

parse->execute;

//点状线

main->init[style = dotted];

main->cleanup;

//连接了两条线

execute->{make_string;printf}

init->make_string;

//把边的默认颜色设为red

edge [color = red];

main->printf [sytle=bold, label = "100times"];

//节点的名称

make_string [label = "make a\nstring"];

//设置节点的默认属性

node [shape=box,style =filled,color=lightgrey];

execute->compare;

}

多边形

digraph G{

a -> b -> c;

b -> d;

/* 形状为多边形,边数为5,外框为3条,颜色为淡蓝,样式为填充 */

a [shape = polygon, sides = 5, peripheries = 3, color = lightblue, style = filled];

/* 形状为多边形,边数为4,角的倾斜度为0.4,内容为hellow world*/

c [shape = polygon, sides = 4, skew = 0.4, label = "hello world"];

/* 形状为倒三角,整体旋转30度 */

d [shape = invtriangle,orientation = 30];

/* 形状为多边形,边数为4,扭曲度为0.7 */

e [shape = polygon, sides = 4, distortion = 0.7];

}

数据结构

(1)复杂的标签

digraph structs {

/* 把节点的默认形状设为矩形record,默认的是圆角矩形Mrecord */

node [shape = record];

struct1 [label = "left|middle|right"];

struct2 [label = "one|two"];

struct3 [label = "hello\nworld|{b|{c|d|e}|f}|g|h"];

struct1 -> struct2;

struct1 -> struct3;

}

graph picture {

//这幅图的名字

label = "I love you";

//图名字的位置在bottom,也可以是t

labelloc = b;

//图名字的位置在left,也可以是r

labeljust = l;

edge[decorate = true];

C -- D [label = "s1"];

C -- E [label = "s2"];

C -- F [label = "s3"];

D -- E [label = "s4"];

D -- F [label = "s5"];

edge[decorate = false, labelfontcolor = blue, fontcolor = red];

C1 -- D1 [headlabel = "c1",taillabel = "d1",label = "c1 - d1"];

}

(2)行列对齐

digraph html {

rankdir = LR;

{

node[shape = plaintext];

1995 -> 1996 -> 1997 -> 1998 -> 1999 -> 2000 -> 2001;

}

{

node[shape = box, style = filled];

WAR3 -> Xhero -> Footman -> DOTA:

WAR3 -> Battleship;

}

{rank = same; 1996; WAR3;}

{rank = same; 1998; Xhero; Battleship;}

{rank = same; 1999; Footman;}

{rank = same; 2001; DOTA;}

}

(3)二叉树

digraph G {

label = "Binary search tree";

node [shape = record];

A [label = "|A|"];

B [label = "|B|"];

C [label = "|C|"];

D [label = "|D|"];

E [label = "|E|"];

F [label = "|F|"];

G [label = "|G|"];

A:f0 -> B:f1;

A:f2 -> C:f1;

B:f0 -> D:f1;

B:f2 -> E:f1;

C:f0 -> F:f1;

C:f2 -> G:f1;

}

(4)哈希表

digraph G{

nodesep = .05;

rankdir = LR;

node [shape = record,width = .1,height = .1];

node0 [label = "|||||||",height = 2.5];

node [width = 1.5];

node1 [label = "{n14|719|

}"];

node2 [label = "{a1|805|

}"];

node3 [label = "{i9|718|

}"];

node4 [label = "{e5|989|

}"];

node5 [label = "{t20|959|

}"];

node6 [label = "{o15|794|

}"];

node7 [label = "{s19|659|

}"];

node0:f0 -> node1:n;

node0:f1 -> node2:n;

node0:f2 -> node3:n;

node0:f5 -> node4:n;

node0:f6 -> node5:n;

node2:p -> node6:n;

node4:p -> node7:n;

}

流程图

digraph G{

subgraph cluster0 {

node [style = filled,color = white];

style = filled;

color = lightgrey;

a0 -> a1 -> a2 -> a3;

label = "process #1";

}

subgraph cluster1 {

node [style = filled];

b0 -> b1 -> b2 -> b3;

label = "process #2";

color = blue;

}

start -> a0;

start -> b0;

a1 -> b3;

b2 -> a3;

a3 -> a0;

a3 -> end;

b3 -> end;

start [shape = Mdiamond];

end [shape = Msquare];

}

Reference

graphviz linux教程,程序员绘图利器 — Graphviz相关推荐

  1. 一分钟,六张图让您看懂Linux系统对程序员的重要性。

    文章目录 1.Linux与Windows职位数之比2.6:1 2.C/C++程序员Linux与Windows职位数之比3.5:1 3.88.2%的WEB系统部署在Linux系统下 4.数据解读 5.获 ...

  2. 整理的程序员使用利器(工具)

    技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddit:同上 MSDN:微软相关的官方技术集中地,主要是文档类 infoq:企业级应用,关注软件开发领域 ...

  3. Python程序员Debug利器,和Print说再见 | 技术头条

    整理 | Rachel 责编 | Jane 出品 | Python大本营(id:pythonnews) [导语]程序员每日都在和 debug 相伴.新手程序员需要学习的 debug 手段复杂多样,设置 ...

  4. 程序员必备利器:8 款“珍藏已久”的程序开发利器,瞬间提升效率

    上班摸鱼,感觉今天的天气适合做好物分享,所以,就来给大家介绍8款我珍藏已久的开发者利器!记得点个收藏哟~ FocusFox 互联网是一个令人分心的地方,每天,我们会访问,接触各种各样的网站. 当你想把 ...

  5. [Linux] PHP程序员玩转Linux系列-腾讯云硬盘扩容挂载

    1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...

  6. [Linux] PHP程序员玩转Linux系列-Linux和Windows安装nginx

    1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...

  7. Linux:程序员必备的21条Linux 命令

    一.文件和目录 1. cd命令 (它用于切换当前目录,它的参数是要切换到的目录的路径,可以是绝对路径,也可以是相对路径) cd /home    进入 '/ home' 目录 cd ..       ...

  8. 程序员开发windows linux,好程序员不用windows作开发环境

    好程序员不用windows作为开发环境,今天我想就这个点吐槽一下.最近因为工作关系,需要在windows机器上工作一段时间,作为一个用了多年windows,然后切换到ubuntu作为工作环境两年时间, ...

  9. [Linux] PHP程序员玩转Linux系列-nginx初学者引导

    1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...

最新文章

  1. 阿里巴巴的持久层抛弃了hibernate,采用的却是MyBatis框架。。。
  2. 【数据结构与算法】之深入解析“买卖股票的最好时机II”的求解思路与算法示例
  3. ifram 表单post 方法免密登录的实现
  4. [css] 写出几个初始化CSS的样式,并解释说明为什么要这样写
  5. 小黄鸡 php,PHP调用小黄鸡 api post发送
  6. jQuery EasyUI API 中文文档 - 组合表格(ComboGrid)
  7. date、clock、hwclock时间命令解释
  8. 51nod-1422:沙拉酱前缀
  9. 串口通信----串口接收框接收不到数据
  10. Proteus8.9 下载与安装 以及大多数问题
  11. 软件测试(白盒测试入门之gtest测试)
  12. 在线编辑Word——插入图片、图形
  13. APR-服务器端编程
  14. 手机连不上电脑热点、热点连接超时、电脑热点无法被连接的问题-01
  15. Ubuntu神奇地变成了只读文件系统的错误--修复方法
  16. 18日精读掌握《费曼物理学讲义-卷一》计划(2019/6/12-2019/6/29)
  17. 两点三次埃尔米特插值
  18. 数据库索引,到底是什么做的?-- 转自沈剑公众号
  19. Java 使用iframe的简单功能页面
  20. SpringSecurity:密码登录与token登录过程理解

热门文章

  1. android fragment概念,android Fragment相关概念简介
  2. java电台数据解析_Java数据解析---SAX
  3. python bool类型_Python 的内置数值类型
  4. linux之sed命令n,N,d,D,p,P,h,H,g,G,x解析
  5. ldd查看可执行程序的依赖库
  6. 使用xdebug+wincachegrind的心得
  7. 高级mysql优化知识_MySQL高级第三篇(索引优化分析)
  8. 分时线的9代表什么_为什么要打板?资深股民分享打板技巧和思路,句句精辟!...
  9. mysql5.7只安装服务端_Windows Mysql5.7.11 服务端安装详解
  10. slack 国内 android,使用Slack Api登录,Android