Drawing tool for programmers-Graphviz

Source: Internet
Author: User
Tags dota

Drawing tool for programmers-Graphviz
Overview

Official Website: http://www.graphviz.org/

Graphviz (Graph Visualization Software) is an open-source toolkit started by AT&T lab. DOT is a graphic description language, which is very simple,

Graphviz is a tool used to process this language. You can use Graphviz to plot the DOT language. It is especially useful to programmers.

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

Undirected graph
graph graphname {    a -- b -- c;    b -- d;}

 

Directed Graph
digraph graphname {    a -> b -> c;    b -> d;}

 

Attribute
// In the DOT language, you can add different attributes for vertices and edges. Digraph graphname {// node attributes, node name a [lable = "Foo"]; // node attributes, node shape B [shape = box]; // edge attributes, edge color a-> B-> c [color = blue]; // edge attributes, linear B-> d [style = dotted];}

 

Basic graphics
Digraph G {// set the image size to 4 inch * 4 inchsize = ""; main [shape = box]; // edge importance, the default value is 1main-> parse [weight = 8]; parse-> execute; // point line main-> init [style = dotted]; main-> cleanup; // two lines are connected: execute-> {make_string; printf} init-> make_string; // set the default color of the edge to rededge [color = red]; main-> printf [sytle = bold, label = "100 times"]; // node name make_string [label = "make a \ nstring"]; // set the default node attribute node [shape = box, style = filled, color = lightgrey]; execute-> compare ;}

 

 

Polygon
Digraph G {a-> B-> c; B-> d;/* returns a Polygon Shape. The edges are 5, the outer frame is 3, and the color is light blue, fill in the style */a [shape = polygon, sides = 5, peripheries = 3, color = lightblue, style = filled];/* The shape is polygon and the number of edges is 4, the angle tilt is 0.4, the content is hellow world */c [shape = polygon, sides = 4, skew = 0.4, label = "hello world"];/* The shape is inverted triangle, the overall rotation is 30 degrees */d [shape = invtriangle, orientation = 30];/* The shape is polygon, the number of edges is 4, and the curvature is 0.7 */e [shape = polygon, sides = 4, distortion = 0.7];}

 

 

Data Structure

 

(1) complex tags

Digraph structs {/* sets the default shape of a node to a rectangular record. The default shape is the rounded rectangle 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 {// The name label = "I love you" for this image; // The image name is located in bottom, or tlabelloc = B; // The image name is located in left, which can also be rlabeljust = 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) Align rows and columns

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) binary tree

digraph G {label = "Binary search tree";node [shape = record];A [label = "<f0>|<f1>A|<f2>"];B [label = "<f0>|<f1>B|<f2>"];C [label = "<f0>|<f1>C|<f2>"];D [label = "<f0>|<f1>D|<f2>"];E [label = "<f0>|<f1>E|<f2>"];F [label = "<f0>|<f1>F|<f2>"];G [label = "<f0>|<f1>G|<f2>"];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) hash table

digraph G{nodesep = .05;rankdir = LR;node [shape = record,width = .1,height = .1];node0 [label = "<f0>|<f1>|<f2>|<f3>|<f4>|<f5>|<f6>|",height = 2.5];node [width = 1.5];node1 [label = "{<n>n14|719|<p>}"];node2 [label = "{<n>a1|805|<p>}"];node3 [label = "{<n>i9|718|<p>}"];node4 [label = "{<n>e5|989|<p>}"];node5 [label = "{<n>t20|959|<p>}"];node6 [label = "{<n>o15|794|<p>}"];node7 [label = "{<n>s19|659|<p>}"];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;}


 

Flowchart
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

[1] http://zh.wikipedia.org/zh-cn/DOT language, DOT language concise introduction.

[2] http://zh.wikipedia.org/zh/Graphviz, simple background knowledge.

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.