Drawing graphs with dot
Emden R.Gansner and Eleftherios Koutsofios and Stephen North
悉能December22,2009
Abstract
慰问困难群众简报dot draws directed graphs as hierarchies.It runs as a command line pro-gram,web visualization rvice,or with a compatible graphical interface. Its features include well-tuned layout algorithms for placing nodes and edge splines,edge labels,“record”shapes with“ports”for drawing data struc-tures;cluster layouts;and an underlyingfile language for stream-oriented graph tools.Below is a reduced module dependency graph of an SML-NJ compiler that took0.23conds of ur time on a3GHz Intel Xeon.
1
1Basic Graph Drawing
dot draws directed graphs.It reads attributed graph textfiles and writes drawings, either as graphfiles or in a graphics format such as GIF,PNG,SVG,PDF,or PostScript.
霄字五行属什么dot draws graphs in four main phas.Knowing this helps you to understand what kind of layouts dot makes and how you can control them.The layout proce-dure ud by dot relies on the graph being acyclic.Thus,thefirst step is to break any cycles which occur in the input graph by reversing the internal direction of certain cyclic edges.The next step assigns nodes to discrete ranks or levels.In a top-to-bottom drawing,ranks determine Y coordinates.Edges that span more than one rank are broken into chains of“virtual”nodes and unit-length edges.The third step orders nodes within ranks to avoid crossings.The fourth step ts X coordi-nates of nodes to keep edges short,and thefinal step routes edge splines.This is the same general approach as most hierarchical graph drawing programs,bad on the work of Warfield[War77],Carpano[Car80]and Sugiyama[STT81].We refer the reader to[GKNV93]for a thorough explanation of dot’s algorithms.怎么做鲍鱼
dot accepts input in the DOT language(cf.Appendix D).This language de-scribes three main kinds of objects:graphs,nodes,and edges.The main(outer-most)graph can be directed(digraph)or undirected graph.Becau dot makes layouts of directed graphs,all the following examples u digraph.(A parate layout utility,neato,draws undirected graphs[Nor92].)Within a main graph,a subgraph defines a subt of nodes and edges.
Figure1is an example graph in the DOT language.Line1gives the graph name and type.The lines tha
t follow create nodes,edges,or subgraphs,and t attributes.Names of all the objects may be C identifiers,numbers,or quoted C strings.Quotes protect punctuation and white space.
A node is created when its namefirst appears in thefile.An edge is created when nodes are joined by the edge operator->.In the example,line2makes edges from main to par,and from par to execute.Running dot on thisfile(call it graph1.dot)
$dot-Tps graph1.dot-o graph1.ps
yields the drawing of Figure2.The command line option-Tps lects PostScript (aph1.ps may be printed,displayed by a PostScript viewer,or embedded in another document.
一个女人的心It is often uful to adjust the reprentation or placement of nodes and edges in the layout.This is done by tting attributes of nodes,edges,or subgraphs in the inputfile.Attributes are name-value pairs of character strings.Figures3and4 illustrate some layout attributes.In the listing of Figure3,line2ts the graph’s
1:digraph G{
2:main->par->execute;
3:main->init;
4:main->cleanup;
5:execute->make_string;
6:execute->printf
7:init->make_string;cpu坏了
8:main->printf;
9:execute->compare;
10:}
Figure1:Small graph
Figure2:Drawing of small graph
建筑工程复工方案size to4,4(in inches).This attribute controls the size of the drawing;if the drawing is too large,it is scaled uniformly as necessary tofit.
Node or edge attributes are t off in square brackets.In line3,the node main is assigned shape box.The edge in line4is straightened by increasing its weight (the default is1).The edge in line6is drawn as a dotted line.Line8makes edges from execute to make string and printf.In line10the default edge color is t to red.This affects any edges created after this point in thefile.Line11 makes a bold
edge labeled100times.In line12,node make_string is given a multi-line label.Line13changes the default node to be a boxfilled with a shade of blue.The node compare inherits the values.
2Drawing Attributes
The main attributes that affect graph drawing are summarized in Appendices A,B and C.For more attributes and a more complete description of the attributes,you should refer to the Graphviz web site,specifically
2.1Node Shapes
Nodes are drawn,by default,with shape=ellip,width=.75,height=.5 and labeled by the node name.Other common shapes include box,circle, record and plaintext.A list of the main node shapes is given in Appendix H. The node shape plaintext is of particularly interest in that it draws a node with-out any outline,an important convention in some kinds of diagrams.In cas where the graph structure is of main concern,and especially when the graph is moderately large,the point shape reduces nodes to display minimal content.When drawn,a node’s actual size is the greater of the requ
ested size and the area needed for its text label,unless fixedsize=true,in which ca the width and height values are enforced.
Node shapes fall into two broad categories:polygon-bad and record-bad.1 All node shapes except record and Mrecord are considered polygonal,and are modeled by the number of sides(ellips and circles being special cas),and a few other geometric properties.Some of the properties can be specified in a graph.If regular=true,the node is forced to be regular.The parameter
舞狮英语1There is a way to implement custom node shapes,using shape=epsf and the shapefile attribute,and relying on PostScript output.The details are beyond the scope of this ur’s guide. Plea contact the authors for further information.
1:digraph G{
2:size="4,4";
3:main[shape=box];/*this is a comment*/
4:main->par[weight=8];
5:par->execute;
6:main->init[style=dotted];
7:main->cleanup;
8:execute->{make_string;printf}
9:init->make_string;
10:edge[color=red];//so is this
11:main->printf[style=bold,label="100times"]; 12:make_string[label="make a\nstring"];
13:node[shape=box,style=filled,color=".7.3 1.0"]; 14:execute->compare;
15:}
Figure3:Fancy graph
Figure4:Drawing of fancy graph