[Graphviz] Some simple examples (not to be continued)

Source: Internet
Author: User

This article references: http://wenku.baidu.com/link?url=kTPIn5tBY4eboEPZeOZyLwHAq-fSMoTbagsqcG5-IcpL325tnnh3ES8aky-PBjP99KpnH_ dyge41i2kzp3euuaqbdj0pk55kcnif9zcsh6k

1. Simple example of setting the shape and color of points and lines
    • Digraph is a graph, graph is a graph without direction. Used in a direction diagram,-used in an no-map, cannot be mixed.
digraph G {                      //给出了图的类型和名字main -> parse -> execute;        //当一个点第一次出现,它就被创建了main -> init;                    //用->标识符创建一条边main -> cleanup;execute -> make_string;execute -> printfinit -> make_string;main -> printf;execute -> compare;}
    • The resulting image
A slightly more complicated example
    • Properties of edges : Sets the properties of the edges in the double brackets behind each edge. You can also set default values for edges with edge.
    • properties of a point : You must set a property for each point individually, and node represents the default value for the point.
    • Rmk
      • The default parameters for points are shape=ellipse, width=.75, height=.5 and labeled by the node name.
      • Some of the dots are shaped in appendix.h, and some commonly used shapes are Bos, circle, record, plaintext.
digraph G {size= "bis"; Set the size of the figure to 4 inch * 4 Inchmain [shape=box];                              /*this is a comment*///The shape of the main point is set to square main and parse [weight=8];                           Weight is the importance of setting this edge, the default is 1parse-Execute;main, init [style=dotted]; Let the line be dot---cleanup;execute, Main-----{make_string;printf}//This statement is connected two lines at a time init--make_string ; edge[color=red];         So was this//the default color of the edge is set to Redmain, printf [style=bold,label= "];                  Label is to write a line on the side of the word make_string [label= "Make a\nstring"];      Let Make_string become a two-line string (note the \ n) node [shape=box,style=filled,color= "0.7.3 1.0"]; Set the default parameters of the point, blue, is used in the compare execute-and-compare;}
    • The resulting image
An example of a side
    • You can set the direction of each side arrow , with Dir, there is forward (default), Back,both,none four kinds of
digraph html {A -> B [dir = both];B -> C [dir = none];C -> D [dir = back];D -> A [dir = forward];}
    • The resulting image
An example of a point
    • sides to set its number of edges
    • peripheries the number of layers used to set the polygon's outer box
    • regular=true allows your polygon to be a regular
    • orientation=*, you can make your polygon rotate an angle, such as orientation=15 is rotated 15 degrees
    • skew followed by one ( -1.0,1.0) Decimal, which allows you to skew the shape of an angle
    • distortion is to make your graphics produce perspective
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];}
    • The resulting image
Another example of a point
digraph A {A -> B;A [orientation = 15, regular = true, shape = polygon, sides = 8, peripheries = 4, color = red, style = filled];B [shape = polygon, sides = 4, skew = 0.5, color = blue];}
    • The resulting image
Example of a record
    • the difference between record and Mrecord The corners of the Mrecord are round, and the record is a graphic composed of a horizontal and vertical rectangle.
digraph structs {node [shape = record];struct1 [shape = record, label = "<f0> left|<f1> mid\dle|<f2> right"];struct2 [shape = record, label = "<f0> one|<f1> two"];struct3 [shape = record, label = "hello\nworld|{b|{c|
    • The resulting graph
Example of writing on line
    • RMK: When you have a long line and line label, you can decorate=true the properties of the line so that the label of each line is connected to the owning line. You can also add Headlabel and Taillabel to each line, add labels to the starting and ending points of each line, their color is determined by labelfontcolor, and the color of the label is determined by the fontcolor.
graph A {label = "I love you";labelloc = b;labeljust = 1;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"];}
    • The resulting graph
In the HTML language
    • Rmk: In dot we can write a table in HTML language. The HTML language can be introduced with <> instead of "after the label.
 digraph HTML {ABC [shape = none, margin = 0, label =<<table border= "0" cellborder= "1" cellspacing= "0" cellpadding= " 4 "><tr><td rowspan=" 3 "><font color=" Red ">hello</FONT><BR/>world</TD>< TD colspan= "3" >b</td><td rowspan= "3" bgcolor= "Lightgrey" >g</td><td COLSPAN= "3" >h</TD ></TR><TR><TD>C</TD><TD port= "Here" >d</td><td>e</td></tr ><TR><TD colspan= "3" >F</TD></TR></TABLE>>];  
    • The resulting graph

    • below we created a 5*5 table, We can type in the table.

digraph HTML {ABC [shape = none, margin = 0, label =<<table border= "0" cellborder= "1" cellspacing= "0" cellpadding= "4 "><tr><td>0</td><td>1</td><td>2</td><td>3</td><td >4</td></tr><tr><td>1</td><td></td><td></td><td ></TD><TD></TD></TR><TR><TD>2</TD><TD></TD><TD> </TD><TD></TD><TD></TD></TR><TR><TD>3</TD><TD>< /td><td></td><td></td><td></td></tr><tr><td>4</td ><td></td><td></td><td></td><td></td></tr></table >>];}
    • The resulting graph
2. Set the location of points and lines (the concept of a sub-graph)
    • By default, the lines in the graph are from top to bottom and can be changed from left to right. At the top of the file plus RANKDIR=LR is from left to right, the default SHITB (Top->bottom), or it can be rl,bt.
    • When there is a time axis and so on, we will need a point to row in a row (column), then use rank, curly brace bar rank=same, and then the need to side by bit input.
?

[Graphviz] Some simple examples (not to be continued)

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.