Debian Codegraph @

doc/dotguide/dotguide.tex

raw
1 \documentclass[11pt]{article}
2 \usepackage{graphicx}
3 \usepackage{times}
4 \pagestyle{myheadings}
5 \addtolength{\topmargin}{-0.75in}
6 \author{Emden R. Gansner and Eleftherios Koutsofios and Stephen North}
7 \def\dot{{\it dot}}
8 \def\dag{{\it dag}}
9 \def\DOT{{\it DOT}}
10 \def\graphviz{{\it Graphviz}}
11 \newcommand{\lastedited}{February 13, 2020}
12 \date{\lastedited}
13 \newcommand{\mymark}{{\it dot} User's Manual, \lastedited \hfil }
14 \markboth{\mymark}{\mymark}
15 \begin{document}
16 \bibliographystyle{alpha}
17 \title{Drawing graphs with \dot}
18 \maketitle
19 \begin{abstract}
20 \noindent
21 {\dot} draws directed graphs as hierarchies.
22 It runs as a command line program, web visualization
23 service, or with a compatible graphical interface.
24 Its features include well-tuned layout algorithms
25 for placing nodes and edge splines, edge labels,
26 ``record'' shapes with ``ports'' for drawing data structures;
27 cluster layouts; and an underlying file language for
28 stream-oriented graph tools.
29 Below is a reduced module dependency graph of an SML-NJ compiler
30 that took 0.23 seconds of user time on a 3 GHz Intel Xeon.
31
32 \vspace*{.25in}
33 \centerline{
34 \includegraphics[width=4.0in]{smlred}
35 }
36 \end{abstract}
37
38 \newpage
39 \section{Basic Graph Drawing}
40 \dot\ draws directed graphs. It reads attributed graph text files and
41 writes drawings, either as graph files or in a graphics format
42 such as GIF, PNG, SVG, PDF, or PostScript.
43
44
45 \if 0
46 {\bf
47 All details are here and up-to-date.
48 The question is which, if any, should be removed,
49 and should the document structure be changed. Some of the
50 appendices might belong in the main body, and parts of the main
51 body (e.g., the attribute tables and command line information)
52 might be better in the appendix. Maybe the Node and Edge Placement
53 section should appear before Drawing Size and Spacing.
54 \fi
55
56 \dot\ draws graphs in four main phases.
57 Knowing this helps you to understand what kind of
58 layouts \dot\ makes and how you can control them.
59 The layout procedure used by \dot\ relies on the graph
60 being acyclic. Thus, the first step is to break any
61 cycles which occur in the input graph by reversing
62 the internal direction of certain cyclic edges.
63 The next step assigns nodes to discrete ranks or levels.
64 In a top-to-bottom drawing, ranks determine $Y$ coordinates.
65 Edges that span more than one rank are broken into chains
66 of ``virtual'' nodes and unit-length edges.
67 The third step orders nodes within ranks to avoid crossings.
68 The fourth step sets $X$ coordinates of nodes to keep edges short,
69 and the final step routes edge splines.
70 This is the same general approach as most hierarchical graph drawing
71 programs, based on the work of Warfield \cite{warfield},
72 Carpano \cite{carpano} and Sugiyama \cite{stt}.
73 We refer the reader to \cite{gknv:methods}
74 for a thorough explanation of \dot's algorithms.
75
76 \dot\ accepts input in the \DOT\ language (cf. Appendix~\ref{grammar}).
77 This language describes three main kinds of objects:
78 graphs, nodes, and edges.
79 The main (outermost) graph can be directed
80 ({\tt digraph}) or undirected {\tt graph}.
81 Because \dot\ makes layouts of directed graphs,
82 all the following examples use {\tt digraph}.
83 (A separate layout utility, {\it neato},
84 draws undirected graphs \cite{neatoguide}.)
85 Within a main graph, a {\tt subgraph} defines a
86 subset of nodes and edges.
87
88 Figure~\ref{fig:graph1} is an example graph in the \DOT\ language.
89 Line 1 gives the graph name and type.
90 The lines that follow create nodes, edges, or subgraphs,
91 and set attributes. Names of all these objects may be
92 C identifiers, numbers, or quoted C strings.
93 Quotes protect punctuation and white space.
94
95 \begin{figure}[p]
96 \begin{verbatim}
97 1: digraph G {
98 2: main -> parse -> execute;
99 3: main -> init;
100 4: main -> cleanup;
101 5: execute -> make_string;
102 6: execute -> printf
103 7: init -> make_string;
104 8: main -> printf;
105 9: execute -> compare;
106 10: }
107 \end{verbatim}
108 \caption{Small graph}
109 \label{fig:graph1}
110 \end{figure}
111
112 \begin{figure}[p]
113 \centerline {
114 \includegraphics[width=3.0in]{graph1}
115 }
116 \caption{Drawing of small graph}
117 \label{fig:drawing1}
118 \end{figure}
119
120 A node is created when its name first appears in the file.
121 An edge is created when nodes are joined by the edge operator \verb"->".
122 In the example, line 2 makes edges from {\it main} to {\it parse},
123 and from {\it parse} to {\it execute}.
124 Running \dot\ on this file (call it \verb"graph1.gv")
125 \begin{verbatim}
126 $ dot -Tps graph1.gv -o graph1.ps
127 \end{verbatim}
128 yields the drawing of Figure~\ref{fig:drawing1}.
129 The command line option \verb"-Tps" selects PostScript (EPSF) output.
130 \verb"graph1.ps" may be printed, displayed by a PostScript viewer,
131 or embedded in another document.
132
133 It is often useful to adjust the representation or placement of nodes
134 and edges in the layout. This is done by setting attributes of nodes,
135 edges, or subgraphs in the input file.
136 Attributes are name-value pairs of character strings.
137 Figures~\ref{fig:graph2} and \ref{fig:drawing2} illustrate
138 some layout attributes. In the listing of Figure~\ref{fig:graph2},
139 line 2 sets the graph's {\tt size} to {\tt 4,4}
140 (in inches).
141 This attribute controls the size of the drawing; if the drawing is
142 too large, it is scaled uniformly as necessary to fit.
143
144 Node or edge attributes are set off in square brackets.
145 In line 3, the node \verb"main" is assigned shape \verb"box".
146 The edge in line 4 is straightened by increasing its
147 \verb"weight" (the default is \verb"1").
148 The edge in line 6 is drawn as a dotted line.
149 Line 8 makes edges from {\tt execute} to {\tt make\_string} and {\tt printf}.
150 In line 10 the default edge color is set to \verb"red".
151 This affects any edges created after this point in the file.
152 Line 11 makes a bold edge labeled {\tt 100 times}.
153 In line 12, node \verb"make_string" is given a multi-line label.
154 Line 13 changes the default node to be a box filled with a shade of blue.
155 The node {\tt compare} inherits these values.
156
157 \begin{figure}[p]
158 \begin{verbatim}
159 1: digraph G {
160 2: size ="4,4";
161 3: main [shape=box]; /* this is a comment */
162 4: main -> parse [weight=8];
163 5: parse -> execute;
164 6: main -> init [style=dotted];
165 7: main -> cleanup;
166 8: execute -> { make_string; printf}
167 9: init -> make_string;
168 10: edge [color=red]; // so is this
169 11: main -> printf [style=bold,label="100 times"];
170 12: make_string [label="make a\nstring"];
171 13: node [shape=box,style=filled,color=".7 .3 1.0"];
172 14: execute -> compare;
173 15: }
174 \end{verbatim}
175 \caption{Fancy graph}
176 \label{fig:graph2}
177 \end{figure}
178
179 \begin{figure}[p]
180 \centerline {
181 \includegraphics[width=2.5in]{graph2}
182 }
183 \caption{Drawing of fancy graph}
184 \label{fig:drawing2}
185 \end{figure}
186
187 \section{Drawing Attributes}
188
189 The main attributes that affect graph drawing
190 are summarized in Appendices~\ref{sec:node_attr},
191 \ref{sec:edge_attr} and \ref{sec:graph_attr}.
192 For more attributes and a more complete description of the attributes, you
193 should refer to the \graphviz\ web site, specifically
194 \begin{center}
195 {\tt www.graphviz.org/doc/info/attrs.html}
196 \end{center}
197
198 \subsection{Node Shapes}
199 \label{sect:shape}
200
201 Nodes are drawn, by default, with {\tt shape=ellipse}, {\tt width=.75},
202 {\tt height=.5} and labeled by the node name.
203 Other common shapes include {\tt box}, {\tt circle}, {\tt record}
204 and {\tt plaintext}.
205 A list of the main node shapes is given in Appendix~\ref{app:shapes}.
206 The node shape {\tt plaintext} is of particularly interest in
207 that it draws a node without any outline, an important convention
208 in some kinds of diagrams. In cases where the graph structure is of
209 main concern, and especially when the graph is moderately large, the
210 {\tt point} shape reduces nodes to display minimal content.
211 When drawn, a node's actual size is the greater of the requested
212 size and the area needed for its text label, unless {\tt fixedsize=true},
213 in which case the {\tt width} and {\tt height} values are enforced.
214
215 Node shapes fall into two broad categories: polygon-based and
216 record-based.\footnote{There is a way to implement custom node shapes,
217 using {\tt shape=epsf} and the {\tt shapefile} attribute, and
218 relying on PostScript output.
219 The details are beyond the scope of this user's guide.
220 Please contact the authors for further information.} All node
221 shapes except {\tt record} and {\tt Mrecord} are considered polygonal,
222 and are modeled by the number of sides (ellipses and circles being
223 special cases), and a few other geometric properties. Some of these
224 properties can be specified in a graph. If {\tt regular=true}, the
225 node is forced to be regular. The parameter {\tt peripheries} sets
226 the number of boundary curves drawn. For example, a doublecircle
227 has {\tt peripheries=2}.
228 The {\tt orientation} attribute specifies a clockwise rotation of the
229 polygon, measured in degrees.
230
231 The shape {\tt polygon} exposes all the polygonal parameters, and
232 is useful for creating many shapes that are not predefined.
233 In addition to the parameters {\tt regular}, {\tt peripheries} and
234 {\tt orientation}, mentioned above, polygons are parameterized by
235 number of sides {\tt sides}, {\tt skew} and {\tt distortion}.
236 {\tt skew} is a floating point number (usually between $-1.0$ and $1.0$)
237 that distorts the shape by slanting it from top-to-bottom,
238 with positive values moving the top of the polygon to the right.
239 Thus, {\tt skew} can be used to turn a box into a parallelogram.
240 {\tt distortion} shrinks the polygon from top-to-bottom, with negative
241 values causing the bottom to be larger than the top. {\tt distortion}
242 turns a box into a trapezoid. A variety of these polygonal attributes
243 are illustrated in Figures~\ref{fig:polygons} and~\ref{fig:polylist}.
244
245 \begin{figure}[p]\footnotesize
246 \begin{verbatim}
247 1: digraph G {
248 2: a -> b -> c;
249 3: b -> d;
250 4: a [shape=polygon,sides=5,peripheries=3,color=lightblue,style=filled];
251 5: c [shape=polygon,sides=4,skew=.4,label="hello world"]
252 6: d [shape=invtriangle];
253 7: e [shape=polygon,sides=4,distortion=.7];
254 8: }
255 \end{verbatim}
256 \caption{Graph with polygonal shapes}
257 \label{fig:polylist}
258 \end{figure}
259 \begin{figure}[p]
260 \centerline {
261 \includegraphics{poly}
262 }
263 \caption{Drawing of polygonal node shapes}
264 \label{fig:polygons}
265 \vspace*{.5in} % tweak to make this figure use rest of page
266 \end{figure}
267
268 Record-based nodes form the other class of node shapes.
269 These include the
270 shapes {\tt record} and {\tt Mrecord}. The two are identical
271 except that the latter has rounded corners. These nodes represent
272 recursive lists of fields, which are drawn as alternating horizontal
273 and vertical rows of boxes. The recursive structure is determined by
274 the node's {\tt label}, which has the following schema: \\
275 \begin{table}[h]
276 \begin{tabular}{lll}
277 {\it rlabel} & $\rightarrow$ & {\it field} ( '$|$' {\it field} )* \\
278 {\it field} & $\rightarrow$ & {\it boxLabel} $|$ '{' {\it rlabel} '}' \\
279 {\it boxLabel} & $\rightarrow$ & [ '$<$' {\it string} '$>$' ] [ {\it string} ] \\
280 \end{tabular}
281 \end{table}
282
283 Literal braces, vertical bars and angle brackets must be escaped.
284 Spaces are interpreted as separators between tokens, so they
285 must be escaped if they are to appear literally in the text.
286 The first string in a {\it boxLabel} gives a name to the field,
287 and serves as a port name for the box (cf. Section~\ref{sect:ports}).
288 The second string is used as a label for the field;
289 it may contain the same escape sequences as multi-line
290 labels (cf. Section~\ref{sect:labels}).
291 The example of Figures~\ref{fig:record} and \ref{fig:recorddrawing}
292 illustrates the use and some properties of records.
293
294 \begin{figure}[p]\footnotesize
295 \begin{verbatim}
296 1: digraph structs {
297 2: node [shape=record];
298 3: struct1 [shape=record,label="<f0> left|<f1> mid\ dle|<f2> right"];
299 4: struct2 [shape=record,label="<f0> one|<f1> two"];
300 5: struct3 [shape=record,label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
301 6: struct1 -> struct2;
302 7: struct1 -> struct3;
303 8: }
304 \end{verbatim}
305 \caption{Records with nested fields}
306 \label{fig:record}
307 \end{figure}
308 \begin{figure}[p]
309 \centerline {
310 \includegraphics{recordex}
311 }
312 \caption{Drawing of records}
313 \label{fig:recorddrawing}
314 \end{figure}
315
316 \subsection{Labels}
317 \label{sect:labels}
318
319 As mentioned above, the default node label is its name.
320 Edges are unlabeled by default.
321 Node and edge labels can be set explicitly using the {\tt label}
322 attribute as shown in
323 Figure~\ref{fig:drawing2}.
324
325 Though it may be convenient to label nodes by name, at other times
326 labels must be set explicitly. For example, in drawing a file
327 directory tree, one might have several directories named {\tt src},
328 but each one must have a unique node identifier.
329 The inode number or full path name are suitable unique identifiers.
330 Then the label of each node can be set to the file name within
331 its directory.
332
333 Multi-line labels can be created by using the escape
334 sequences \verb"\n", \verb"\l", \verb"\r" to terminate
335 lines that are centered, or left or right justified.\footnote{The escape
336 sequence $\backslash$N is an internal symbol for node names.}
337
338 %The node shape {\tt Mdiamond}, {\tt Msquare} and {\tt Mcircle}
339 %use the attributes {\tt toplabel} and {\tt bottomlabel} to specify
340 %additional labels appearing near the top and bottom of the nodes,
341 %respectively.
342
343 Graphs and cluster subgraphs may also have labels. Graph labels
344 appear, by default, centered below the graph. Setting {\tt labelloc=t}
345 centers the label above the graph. Cluster labels appear within the
346 enclosing rectangle, in the upper left corner. The value {\tt labelloc=b}
347 moves the label to the bottom of the rectangle. The setting
348 {\tt labeljust=r} moves the label to the right.
349
350 The default font is 14-point Times-Roman, in black.
351 Other font families, sizes and colors may be selected using the
352 attributes {\tt fontname}, {\tt fontsize} and {\tt fontcolor}.
353 Font names should be compatible with the target interpreter.
354 It is best to use only the standard font families
355 Times, Helvetica, Courier or Symbol as these are guaranteed to work
356 with any target graphics language.
357 For example, \verb"Times-Italic", \verb"Times-Bold", and \verb"Courier"
358 are portable; {\tt AvanteGarde\-DemiOblique} isn't.
359
360 For bitmap output, such as GIF or JPG, \dot\ relies on having these
361 fonts available during layout. Most precompiled installations of
362 \graphviz\ use the fontconfig library for matching font names to
363 available fontfiles. fontconfig comes with a set of utilities for
364 showing matches and installing fonts. Please refer to the fontconfig
365 documentation, or the external \graphviz\ FontFAQ or for further details.
366 If \graphviz\ is built without fontconfig (which usually means you
367 compiled it from source code on your own), the {\tt fontpath} attribute
368 can specify a list of directories\footnote{For Unix-based systems, this is
369 a concatenated list of pathnames, separated by colons. For Windows-based
370 systems, the pathnames are separated by semi-colons.} which should be
371 searched for the font files. If this is not set,
372 \dot\ will use the DOTFONTPATH environment variable or, if this is not
373 set, the GDFONTPATH environment variable. If none of these is set, \dot\
374 uses a built-in list.
375
376 Edge labels are positioned near the center of the edge. Usually, care
377 is taken to prevent the edge label from overlapping edges and
378 nodes. It can still be difficult, in a complex graph, to be certain
379 which edge a label belongs to. If the {\tt decorate} attribute is set
380 to true, a line is drawn connecting the label to its edge. Sometimes
381 avoiding collisions among edge labels and edges forces the
382 drawing to be bigger than desired. If {\tt labelfloat=true},
383 \dot\ does not try to prevent such overlaps, allowing a more compact
384 drawing.
385
386 An edge can also specify additional labels, using {\tt headlabel} and
387 {\tt taillabel}, which are be placed near the ends of the edge.
388 The characteristics of these labels are specified using the attributes
389 {\tt labelfontname}, {\tt labelfontsize} and {\tt labelfontcolor}.
390 These labels are placed near the intersection of the edge and the node
391 and, as such, may interfere with them. To tune a drawing, the user can
392 set the {\tt labelangle} and {\tt labeldistance} attributes.
393 The former sets the angle, in degrees, which the label is rotated from
394 the angle the edge makes incident with the node.
395 The latter sets a multiplicative scaling factor to adjust the distance
396 that the label is from the node.
397
398
399
400 \subsection{HTML-like Labels}
401 \label{sect:html}
402 In order to allow a richer collection of attributes at a finer
403 granularity, \dot\ accepts HTML-like labels using HTML syntax.
404 These are specified using strings that are delimited by
405 $< \ldots >$ rather than double-quotes. Within these delimiters,
406 the string must follow the lexical, quoting, and syntactic
407 conventions of HTML.
408
409 By using the \verb"<TABLE>" element, these labels can be viewed
410 as an extension of and replacement for \verb"shape=record". With
411 these, one can alter colors and fonts at the box level, and include
412 images.
413 The \verb"PORT" attribute of a \verb"<TD>" element
414 provides a port name for the cell (cf. Section~\ref{sect:ports}).
415
416 Although HTML-like labels are just a special type of label attribute,
417 one frequently uses them as though they were a new type of node
418 shape similar to records. Thus, when these are used, one often
419 sees \verb"shape=none" and \verb"margin=0".
420 Also note that, as a label, these can be used with edges and
421 graphs as well as nodes.
422
423 Figures~\ref{fig:htmluse} and \ref{fig:html}
424 give an example of the use of HTML-like labels.
425
426 \begin{figure}[p]\footnotesize
427 \begin{verbatim}
428 1: digraph html {
429 2: abc [shape=none, margin=0, label=<
430 3: <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
431 4: <TR><TD ROWSPAN="3"><FONT COLOR="red">hello</FONT><BR/>world</TD>
432 5: <TD COLSPAN="3">b</TD>
433 6: <TD ROWSPAN="3" BGCOLOR="lightgrey">g</TD>
434 7: <TD ROWSPAN="3">h</TD>
435 8: </TR>
436 9: <TR><TD>c</TD>
437 10: <TD PORT="here">d</TD>
438 11: <TD>e</TD>
439 12: </TR>
440 13: <TR><TD COLSPAN="3">f</TD>
441 14: </TR>
442 15: </TABLE>>];
443 16: }
444 \end{verbatim}
445 \caption{HTML-like labels}
446 \label{fig:htmluse}
447 \end{figure}
448
449 \begin{figure}[p]
450 \centerline {
451 \includegraphics{html}
452 }
453 \caption{Drawing of HTML-like labels}
454 \label{fig:html}
455 \end{figure}
456
457 \subsection{Graphics Styles}
458 \label{sect:style}
459
460 Nodes and edges can specify a {\tt color} attribute, with black
461 the default. This is the color used to draw the node's shape
462 or the edge. A {\tt color} value can be a hue-saturation-brightness triple
463 (three floating point numbers between 0 and 1, separated by commas);
464 one of the colors names listed in Appendix~\ref{app:colors}
465 (borrowed from some version of the X window system); or
466 a red-green-blue (RGB) triple\footnote{A fourth form, RGBA, is also supported,
467 which has the same format as RGB with an additional fourth hexadecimal
468 number specifying alpha channel or transparency information.}
469 (three hexadecimal number between 00 and FF, preceded by the character '\#').
470 Thus, the values {\tt "orchid"}, {\tt "0.8396,0.4862,0.8549"} and
471 {\tt "\#DA70D6"} are three ways to specify the same color.
472 The numerical forms are convenient for scripts or tools that
473 automatically generate colors.
474 Color name lookup is case-insensitive and ignores non-alphanumeric
475 characters, so \verb'warmgrey' and \verb'Warm_Grey' are equivalent.
476
477 We can offer a few hints regarding use of color in graph drawings.
478 First, avoid using too many bright colors.
479 A ``rainbow effect'' is confusing.
480 It is better to choose a narrower range of colors, or
481 to vary saturation along with hue.
482 Second, when nodes are filled with dark or very saturated
483 colors, labels seem to be more readable with \verb"fontcolor=white"
484 and \verb"fontname=Helvetica". (We also have PostScript functions
485 for \dot\ that create outline fonts from plain fonts.)
486 Third, in certain output formats, you can define your own color space.
487 For example, if using PostScript for output, you can redefine
488 \verb"nodecolor", \verb"edgecolor", or \verb"graphcolor"
489 in a library file. Thus, to use RGB colors, place
490 the following line in a file \verb"lib.ps".
491 \begin{verbatim}
492 /nodecolor {setrgbcolor} bind def
493 \end{verbatim}
494 Use the \verb"-l" command line option to load this file.
495 \begin{verbatim}
496 dot -Tps -l lib.ps file.gv -o file.ps
497 \end{verbatim}
498
499 The {\tt style} attribute controls miscellaneous graphics features of
500 nodes and edges.
501 This attribute is a comma-separated list of primitives with
502 optional argument lists.
503 The predefined primitives include \verb"solid", \verb"dashed", \verb"dotted",
504 \verb"bold" and \verb"invis".
505 The first four control line drawing in node boundaries and edges and
506 have the obvious meaning. The value {\tt invis} causes the node or edge
507 to be left undrawn.
508 The style for nodes can also include \verb"filled",
509 \verb"diagonals" and \verb"rounded".
510 \verb"filled" shades inside the node
511 using the color {\tt fillcolor}. If this is not set, the value of
512 {\tt color} is used. If this also is unset,
513 light grey\footnote{The default is black if the output format is MIF,
514 or if the shape is {\tt point}.} is used as the default.
515 The \verb"diagonals" style causes short diagonal lines to be drawn
516 between pairs of sides near a vertex. The \verb"rounded" style rounds
517 polygonal corners.
518
519 User-defined style primitives can be implemented as custom
520 PostScript procedures. Such primitives are executed inside the
521 \verb"gsave" context of a graph, node, or edge, before any of its
522 marks are drawn. The argument lists are translated to PostScript notation.
523 For example, a node with \verb'style="setlinewidth(8)"' is drawn with a
524 thick outline. Here, \verb"setlinewidth" is a PostScript built-in, but
525 user-defined PostScript procedures are called the same way. The
526 definition of these procedures can be given in a library file loaded
527 using \verb"-l" as shown above.
528
529 Edges have a \verb"dir" attribute to set arrowheads.
530 \verb"dir" may be \verb"forward" (the default), \verb"back", \verb"both",
531 or \verb"none". This refers only to where arrowheads are drawn, and does
532 not change the underlying graph. For example, setting \verb"dir=back"
533 causes an arrowhead to be drawn at the tail and no arrowhead at the head,
534 but it does not exchange the endpoints of the edge. The attributes
535 {\tt arrowhead} and {\tt arrowtail} specify the style of arrowhead,
536 if any, which is used at the head and tail ends of the edge.
537 Allowed values are {\tt normal}, {\tt inv}, {\tt dot}, {\tt invdot},
538 {\tt odot}, {\tt invodot} and {\tt none} (cf. Appendix~\ref{app:arrows}).
539 The attribute {\tt arrowsize} specifies a multiplicative factor affecting
540 the size of any arrowhead drawn on the edge.
541 For example, {\tt arrowsize=2.0} makes the arrow twice as long and twice
542 as wide.
543
544 In terms of style and color, clusters act somewhat like large box-shaped
545 nodes, in that the cluster boundary is drawn using the cluster's
546 {\tt color} attribute and, in general, the appearance of the
547 cluster is affected the {\tt style}, {\tt color} and {\tt fillcolor}
548 attributes.
549
550 If the root graph has a {\tt bgcolor} attribute specified, this color is used
551 as the background for the entire drawing, and also serves as the default
552 fill color.
553
554 \subsection{Drawing Orientation, Size and Spacing}
555
556 Two attributes that play an important role in determining the size of
557 a \dot\ drawing are {\tt nodesep} and {\tt ranksep}.
558 The first specifies the minimum distance, in inches, between two
559 adjacent nodes on the same rank.
560 The second deals with rank separation, which is the minimum vertical space
561 between the bottoms of nodes in one rank and the tops of nodes in the next.
562 The {\tt ranksep} attribute sets the rank separation, in inches.
563 Alternatively, one can have {\tt ranksep=equally}. This guarantees
564 that all of the ranks are equally spaced, as measured from the
565 centers of nodes on adjacent ranks. In this case, the rank separation
566 between two ranks is at least the default rank separation. As the
567 two uses of {\tt ranksep} are independent, both can be set at the
568 same time. For example, {\tt ranksep="1.0 equally"} causes ranks to
569 be equally spaced, with a minimum rank separation of 1 inch.
570
571 Often a drawing made with the default node sizes and separations
572 is too big for the target printer or for the space allowed for
573 a figure in a document. There are several ways to try to deal with
574 this problem. First, we will review how \dot\ computes the
575 final layout size.
576
577 A layout is initially made internally at its ``natural'' size,
578 using default settings (unless {\tt ratio=compress} was set,
579 as described below). There is no
580 bound on the size or aspect ratio of the drawing, so if the graph
581 is large, the layout is also large. If you don't specify {\tt size}
582 or {\tt ratio}, then the natural size layout is printed.
583
584 The easiest way to control the output size of the drawing is to
585 set {\tt size="$x$,$y$"} in the graph file (or on the command line
586 using \verb"-G").
587 This determines the size of the final layout.
588 For example, \verb'size="7.5,10"' fits on an 8.5x11 page
589 (assuming the default page orientation)
590 no matter how big the initial layout.
591
592 \verb"ratio" also affects layout size.
593 There are a number of cases, depending on the settings of {\tt size}
594 and {\tt ratio}.
595
596 {\bf Case 1.} \verb"ratio" was not set.
597 If the drawing already fits within the given \verb"size", then nothing happens.
598 Otherwise, the drawing is reduced uniformly enough to make the critical
599 dimension fit.
600
601 If \verb"ratio" was set, there are four subcases.
602
603 {\bf Case 2a.} If \verb"ratio="$x$ where $x$ is a floating point number,
604 then the drawing is scaled up in one dimension to achieve the requested
605 ratio expressed as drawing $height/width$.
606 For example, \verb"ratio=2.0" makes the drawing twice as high
607 as it is wide. Then the layout is scaled using \verb"size" as in Case 1.
608
609 {\bf Case 2b.} If \verb"ratio=fill" and \verb"size="$x,y$ was set,
610 then the drawing is scaled up in one dimension to achieve the ratio
611 $y/x$.
612 Then scaling is performed as in Case 1.
613 The effect is that all of the bounding box given by \verb"size" is filled.
614
615 {\bf Case 2c.} If \verb"ratio=compress"
616 and \verb"size="$x,y$ was set, then the initial layout is compressed
617 to attempt to fit it in the given bounding box. This trades off
618 layout quality, balance and symmetry in order to pack the layout more tightly.
619 Then scaling is performed as in Case 1.
620
621 {\bf Case 2d.} If \verb"ratio=auto" and the {\tt page} attribute is
622 set and the graph cannot be drawn on a single page,
623 then \verb"size" is ignored and \dot\ computes an ``ideal'' size.
624 In particular, the size in a given dimension will be the smallest integral
625 multiple of the page size in that dimension which is at least half
626 the current size.
627 The two dimensions are then scaled independently to the new size.
628 \if 0
629 {\bf I don't think this code takes into account page margins or that
630 the output might be rotated. Should it?}
631 \fi
632
633 If \verb"rotate=90" is set, or {\tt orientation=landscape},
634 then the drawing is rotated $90^\circ$ into landscape mode.
635 The $X$ axis of the layout would be along the $Y$ axis of each page.
636 This does not affect \dot's interpretation of \verb"size",
637 \verb"ratio" or \verb"page".
638
639 At this point, if \verb"page" is not set, then the final layout is
640 produced as one page.
641
642 If \verb"page="$x,y$ is set, then the layout is printed as a sequence
643 of pages which can be tiled or assembled into a mosaic. Common settings
644 are \verb'page="8.5,11"' or \verb'page="11,17"'. These values
645 refer to the full size of the physical device; the actual area used
646 will be reduced by the margin settings.
647 (For printer output, the default is 0.5 inches;
648 for bitmap-output, the $X$ and $Y$
649 margins are 10 and 2 points, respectively.)
650 For tiled layouts, it may be helpful to set smaller margins.
651 This can be done
652 by using the {\tt margin} attribute. This can take a single number,
653 used to set both margins, or two numbers separated by a comma to set the
654 $x$ and $y$ margins separately. As usual, units are in inches. Although one can
655 set \verb"margin=0", unfortunately, many bitmap printers have an
656 internal hardware margin that cannot be overridden.
657
658 The order in which pages are printed can be controlled by the
659 {\tt pagedir} attribute. Output is always done using a row-based or
660 column-based ordering,
661 and {\tt pagedir} is set to a two-letter code specifying the major
662 and minor directions. For example, the default is {\tt BL}, specifying
663 a bottom-to-top ({\tt B}) major order and a left-to-right ({\tt L})
664 minor order. Thus,
665 the bottom row of pages is emitted first, from left to right, then the
666 second row up, from left to right, and finishing with the top row,
667 from left to right. The top-to-bottom order is represented by {\tt T}
668 and the right-to-left order by {\tt R}.
669
670 If {\tt center=true} and the graph can be output on one page, using the
671 default page size of 8.5 by 11 inches if {\tt page} is not set, the
672 graph is repositioned to be centered on that page.
673
674 A common problem is that a large graph drawn at a small size
675 yields unreadable node labels.
676 To make larger labels, something has to give.
677 There is a limit to the amount of readable text that can fit on one page.
678 Often you can draw a smaller graph by extracting an interesting
679 piece of the original graph before running \dot.
680 We have some tools that help with this.
681 \begin{description}
682 \item [sccmap] decompose the graph into strongly connected components
683 \item [tred] compute transitive reduction (remove edges implied by transitivity)
684 \item [gvpr] graph processor to select nodes or edges, and contract
685 or remove the rest of the graph
686 \item [unflatten] improve aspect ratio of trees by staggering the lengths
687 of leaf edges
688 \end{description}
689
690 With this in mind, here are some thing to try on a given graph:
691 \begin{enumerate}
692 \item Increase the node \verb"fontsize".
693 \item Use smaller \verb"ranksep" and \verb"nodesep".
694 \item Use \verb"ratio=auto".
695 \item Use \verb"ratio=compress" and give a reasonable \verb"size".
696 \item A sans serif font (such as Helvetica) may be more readable than Times
697 when reduced.
698 \end{enumerate}
699
700 \subsection{Node and Edge Placement}
701
702 Attributes in \dot\ provide many ways to adjust the large-scale
703 layout of nodes and edges, as well as fine-tune the drawing to
704 meet the user's needs and tastes. This section discusses these
705 attributes\footnote{For completeness, we note that \dot\ also provides
706 access to various parameters which play technical roles in the
707 layout algorithms. These include {\tt mclimit},
708 {\tt nslimit}, {\tt nslimit1}, {\tt remincross} and {\tt searchsize}.}.
709
710 Sometimes it is natural to make edges point from left to right
711 instead of from top to bottom.
712 If \verb"rankdir=LR" in the top-level graph, the drawing is rotated
713 in this way. \verb"TB" (top to bottom) is the default. The mode
714 \verb"rankdir=BT" is useful for drawing upward-directed graphs.
715 For completeness, one can also have \verb"rankdir=RL".
716
717 In graphs with time-lines, or in drawings that emphasize source and sink nodes,
718 you may need to constrain rank assignments.
719 The \verb"rank" of a subgraph may be set to {\tt same}, {\tt min},
720 {\tt source}, {\tt max} or {\tt sink}.
721 A value {\tt same} causes all the nodes in the subgraph to occur
722 on the same rank. If set to {\tt min}, all the nodes in the subgraph
723 are guaranteed to be on a rank at least as small as any other node in the
724 layout\footnote{Recall that the minimum rank occurs at the top of a drawing.}.
725 This can be made strict by setting {\tt rank=source}, which
726 forces the nodes in the subgraph to be on some rank strictly smaller
727 than the rank of any other nodes (except those also specified by
728 {\tt min} or {\tt source} subgraphs).
729 The values {\tt max} or {\tt sink} play an analogous role for the
730 maximum rank.
731 Note that these constraints induce equivalence classes of nodes. If one
732 subgraph forces nodes {\tt A} and {\tt B} to be on the same rank, and
733 another subgraph forces nodes {\tt C} and {\tt B} to share a rank, then
734 all nodes in both subgraphs must be drawn on the same rank.
735 Figures~\ref{fig:asde91} and \ref{fig:asde91drawing}
736 illustrate using subgraphs for controlling rank assignment.
737
738 \begin{figure}[p]
739 \scriptsize
740 \begin{verbatim}
741 digraph asde91 {
742 ranksep=.75; size = "7.5,7.5";
743
744 {
745 node [shape=plaintext, fontsize=16];
746 /* the time-line graph */
747 past -> 1978 -> 1980 -> 1982 -> 1983 -> 1985 -> 1986 ->
748 1987 -> 1988 -> 1989 -> 1990 -> "future";
749 /* ancestor programs */
750 "Bourne sh"; "make"; "SCCS"; "yacc"; "cron"; "Reiser cpp";
751 "Cshell"; "emacs"; "build"; "vi"; "<curses>"; "RCS"; "C*";
752 }
753
754 { rank = same;
755 "Software IS"; "Configuration Mgt"; "Architecture & Libraries";
756 "Process";
757 };
758
759 node [shape=box];
760 { rank = same; "past"; "SCCS"; "make"; "Bourne sh"; "yacc"; "cron"; }
761 { rank = same; 1978; "Reiser cpp"; "Cshell"; }
762 { rank = same; 1980; "build"; "emacs"; "vi"; }
763 { rank = same; 1982; "RCS"; "<curses>"; "IMX"; "SYNED"; }
764 { rank = same; 1983; "ksh"; "IFS"; "TTU"; }
765 { rank = same; 1985; "nmake"; "Peggy"; }
766 { rank = same; 1986; "C*"; "ncpp"; "ksh-i"; "<curses-i>"; "PG2"; }
767 { rank = same; 1987; "Ansi cpp"; "nmake 2.0"; "3D File System"; "fdelta";
768 "DAG"; "CSAS";}
769 { rank = same; 1988; "CIA"; "SBCS"; "ksh-88"; "PEGASUS/PML"; "PAX";
770 "backtalk"; }
771 { rank = same; 1989; "CIA++"; "APP"; "SHIP"; "DataShare"; "ryacc";
772 "Mosaic"; }
773 { rank = same; 1990; "libft"; "CoShell"; "DIA"; "IFS-i"; "kyacc"; "sfio";
774 "yeast"; "ML-X"; "DOT"; }
775 { rank = same; "future"; "Adv. Software Technology"; }
776
777 "PEGASUS/PML" -> "ML-X";
778 "SCCS" -> "nmake";
779 "SCCS" -> "3D File System";
780 "SCCS" -> "RCS";
781 "make" -> "nmake";
782 "make" -> "build";
783 .
784 .
785 .
786 }
787 \end{verbatim}
788 \caption{Graph with constrained ranks}
789 \label{fig:asde91}
790 \end{figure}
791
792 \begin{figure}[p]
793 \centerline {
794 \includegraphics[width=6in]{asde91}
795 }
796 \caption{Drawing with constrained ranks}
797 \label{fig:asde91drawing}
798 \end{figure}
799
800 In some graphs, the left-to-right ordering of nodes is important.
801 If a subgraph has \verb"ordering=out", then out-edges within the
802 subgraph that have the same tail node wll fan-out from left to right
803 in their order of creation. (Also note that flat edges involving the
804 head nodes can potentially interfere with their ordering.)
805
806 There are many ways to fine-tune the layout of nodes and edges. For
807 example, if the nodes of an edge both have the same {\tt group}
808 attribute, \dot\ tries to keep the edge straight and avoid
809 having other edges cross it.
810 The {\tt weight} of an edge provides another way to keep edges
811 straight. An edge's {\tt weight} suggests some measure of an edge's importance;
812 thus, the heavier the weight, the closer together its nodes should be.
813 \dot\ causes edges with heavier weights to be drawn shorter and straighter.
814
815 Edge weights also play a role when nodes are constrained to the same rank.
816 Edges with non-zero weight between these nodes
817 are aimed across the rank in the same direction
818 (left-to-right, or top-to-bottom in a rotated drawing) as far as possible.
819 This fact may be exploited to adjust node ordering by placing
820 invisible edges (\verb'style="invis"') where needed.
821
822 The end points of edges adjacent to the same node can be constrained
823 using the {\tt samehead} and {\tt sametail} attributes. Specifically,
824 all edges with the same head and the same value of {\tt samehead}
825 are constrained to intersect the head node at the same point. The
826 analogous property holds for tail nodes and {\tt sametail}.
827
828 During rank assignment, the head node of an edge is constrained to be
829 on a higher rank than the tail node. If the edge has {\tt constraint=false},
830 however, this requirement is not enforced.
831
832 In certain circumstances, the user may desire that the end points of
833 an edge never get too close. This can be obtained by setting the
834 edge's {\tt minlen} attribute. This defines the minimum difference
835 between the ranks of the head and tail. For example, if {\tt minlen=2},
836 there will always be at least one intervening rank between the head and tail.
837 Note that this is not concerned with the geometric distance between the
838 two nodes.
839
840 Fine-tuning should be approached cautiously. \dot\ works
841 best when it can makes a layout without much ``help'' or
842 interference in its placement of individual nodes and edges.
843 Layouts can be adjusted somewhat by increasing the \verb"weight" of
844 certain edges, or by creating invisible edges or nodes using \verb"style=invis",
845 and sometimes even by rearranging the order of nodes and edges in the file.
846 But this can backfire because the layouts are
847 not necessarily stable with respect to changes in the input graph.
848 One last adjustment can invalidate all previous changes and make
849 a very bad drawing. A future project we have in mind is to combine
850 the mathematical layout techniques of \dot\ with an interactive
851 front-end that allows user-defined hints and constraints.
852
853 \section{Advanced Features}
854
855 \subsection{Node Ports}
856 \label{sect:ports}
857
858 A node port is a point where edges can attach to a node.
859 (When an edge is not attached to a port, it is aimed at the node's center
860 and the edge is clipped at the node's boundary.)
861
862 There are two types of ports. Ports based on the
863 8 compass points {\tt "n"}, {\tt "ne"}, {\tt "e"}, {\tt "se"},
864 {\tt "s"}, {\tt "sw"}, {\tt "w"} or {\tt "nw"} can be specified
865 for any node. The end of the
866 edge will then be aimed at that position on the node. Thus, if
867 {\tt se} port is specified, the edge will connect to the node at
868 its southeast ``corner''.
869
870 In addition, nodes with a {\tt record} shape can use the
871 record structure to define ports, while HTML-like labels
872 with tables can make any cell a port using the
873 \verb"PORT" attribute of a \verb"<TD>" element.
874 If a record box or table cell defines a port name,
875 an edge can use that port name
876 to indicate that it should be aimed at
877 the center of the box.
878 (By default, the edge is clipped to the box's boundary.)
879
880 There are also two ways to specify ports. One way is to use
881 an edge's {\tt headport} and {\tt tailport} attributes, e.g.
882 \begin{verbatim}
883 a -> b [headport=se]
884 \end{verbatim}
885 Alternatively, the portname can be used to modify the node name as part of the
886 edge declaration using the syntax {\tt {\it node\_name}:{\it port\_name}}.
887 Thus, another way to handle the example given above would be
888 \begin{verbatim}
889 a -> b:se
890 \end{verbatim}
891
892 Since a record box has its own corners, one can add a compass point
893 port to record name port. Thus, the edge
894 \begin{verbatim}
895 a -> b:f0:se
896 \end{verbatim}
897 will attach to the southeast corner of the box in record node {\tt b}
898 whose port name is {\tt f0}.
899
900 Figure~\ref{fig:tree} illustrates the declaration and use of
901 port names in record nodes, with the resulting drawing shown
902 in Figure \ref{fig:treedrawing}.
903
904 \begin{figure}[p]\footnotesize
905 \begin{verbatim}
906 1: digraph g {
907 2: node [shape = record,height=.1];
908 3: node0[label = "<f0> |<f1> G|<f2> "];
909 4: node1[label = "<f0> |<f1> E|<f2> "];
910 5: node2[label = "<f0> |<f1> B|<f2> "];
911 6: node3[label = "<f0> |<f1> F|<f2> "];
912 7: node4[label = "<f0> |<f1> R|<f2> "];
913 8: node5[label = "<f0> |<f1> H|<f2> "];
914 9: node6[label = "<f0> |<f1> Y|<f2> "];
915 10: node7[label = "<f0> |<f1> A|<f2> "];
916 11: node8[label = "<f0> |<f1> C|<f2> "];
917 12: "node0":f2 -> "node4":f1;
918 13: "node0":f0 -> "node1":f1;
919 14: "node1":f0 -> "node2":f1;
920 15: "node1":f2 -> "node3":f1;
921 16: "node2":f2 -> "node8":f1;
922 17: "node2":f0 -> "node7":f1;
923 18: "node4":f2 -> "node6":f1;
924 19: "node4":f0 -> "node5":f1;
925 20: }
926 \end{verbatim}
927 \caption{Binary search tree using records}
928 \label{fig:tree}
929 \end{figure}
930
931 \begin{figure}[p]
932 \centerline {
933 \includegraphics[height=2.5in]{tree}
934 }
935 \caption{Drawing of binary search tree}
936 \label{fig:treedrawing}
937 \end{figure}
938
939 Figures~\ref{fig:structs} and \ref{fig:structdrawing}
940 give another example of the use of record nodes and ports.
941 This repeats the example of
942 Figures~\ref{fig:record} and \ref{fig:recorddrawing}
943 but now using ports as connectors for edges.
944 Note that records sometimes look better if their input height is set
945 to a small value, so the text labels dominate the actual size, as
946 illustrated in Figure~\ref{fig:tree}. Otherwise the default node
947 size ($.75$ by $.5$) is assumed, as in Figure~\ref{fig:structdrawing}.
948 \begin{figure}[p]\footnotesize
949 \begin{verbatim}
950 1: digraph structs {
951 2: node [shape=record];
952 3: struct1 [shape=record,label="<f0> left|<f1> middle|<f2> right"];
953 4: struct2 [shape=record,label="<f0> one|<f1> two"];
954 5: struct3 [shape=record,label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
955 6: struct1:f1 -> struct2:f0;
956 7: struct1:f2 -> struct3:here;
957 8: }
958 \end{verbatim}
959 \caption{Records with nested fields (revisited)}
960 \label{fig:structs}
961 \end{figure}
962 \begin{figure}[p]
963 \centerline {
964 \includegraphics{structs}
965 }
966 \caption{Drawing of records (revisited)}
967 \label{fig:structdrawing}
968 \end{figure}
969 The example of Figures~\ref{fig:hashtable} and \ref{fig:hashtabledrawing}
970 uses left-to-right drawing in a layout of a hash table.
971 \begin{figure}[p]\footnotesize
972 \begin{verbatim}
973 1: digraph G {
974 2: nodesep=.05;
975 3: rankdir=LR;
976 4: node [shape=record,width=.1,height=.1];
977 5:
978 6: node0 [label = "<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> | ",height=2.5];
979 7: node [width = 1.5];
980 8: node1 [label = "{<n> n14 | 719 |<p> }"];
981 9: node2 [label = "{<n> a1 | 805 |<p> }"];
982 10: node3 [label = "{<n> i9 | 718 |<p> }"];
983 11: node4 [label = "{<n> e5 | 989 |<p> }"];
984 12: node5 [label = "{<n> t20 | 959 |<p> }"] ;
985 13: node6 [label = "{<n> o15 | 794 |<p> }"] ;
986 14: node7 [label = "{<n> s19 | 659 |<p> }"] ;
987 15:
988 16: node0:f0 -> node1:n;
989 17: node0:f1 -> node2:n;
990 18: node0:f2 -> node3:n;
991 19: node0:f5 -> node4:n;
992 20: node0:f6 -> node5:n;
993 21: node2:p -> node6:n;
994 22: node4:p -> node7:n;
995 23: }
996 \end{verbatim}\vspace*{-.25in}
997 \caption{Hash table graph file}
998 \label{fig:hashtable}
999 \end{figure}
1000
1001 \begin{figure}[p]
1002 \centerline {
1003 \includegraphics[height=2.5in]{hashtable}
1004 }
1005 \caption{Drawing of hash table}
1006 \label{fig:hashtabledrawing}
1007 \end{figure}
1008
1009 \subsection{Clusters}
1010
1011 A cluster is a subgraph placed in its own distinct rectangle of the layout.
1012 A subgraph is recognized as a cluster when its name has the prefix
1013 \verb"cluster". (If the top-level graph has {\tt clusterrank=none},
1014 this special processing is turned off).
1015 Labels, font characteristics and the {\tt labelloc} attribute can
1016 be set as they would be for the top-level graph, though
1017 cluster labels appear above the graph by default.
1018 For clusters, the label is left-justified by default;
1019 if {\tt labeljust="r"}, the label is right-justified.
1020 The {\tt color} attribute specifies the color of the enclosing rectangle.
1021 In addition, clusters may have {\tt style="filled"}, in which case
1022 the rectangle is filled with the color specified by {\tt fillcolor}
1023 before the cluster is drawn. (If {\tt fillcolor} is not specified,
1024 the cluster's {\tt color} attribute is used.)
1025
1026 Clusters are drawn by a recursive technique that computes a
1027 rank assignment and internal ordering of nodes within clusters.
1028 Figure~\ref{fig:clust1} through \ref{fig:callgraph} are cluster layouts
1029 and the corresponding graph files.
1030
1031 \begin{figure}[p]
1032 \begin{minipage}[t]{2.5in}
1033 \footnotesize
1034 \begin{verbatim}
1035 digraph G {
1036 subgraph cluster0 {
1037 node [style=filled,color=white];
1038 style=filled;
1039 color=lightgrey;
1040 a0 -> a1 -> a2 -> a3;
1041 label = "process #1";
1042 }
1043
1044 subgraph cluster1 {
1045 node [style=filled];
1046 b0 -> b1 -> b2 -> b3;
1047 label = "process #2";
1048 color=blue
1049 }
1050 start -> a0;
1051 start -> b0;
1052 a1 -> b3;
1053 b2 -> a3;
1054 a3 -> a0;
1055 a3 -> end;
1056 b3 -> end;
1057
1058 start [shape=Mdiamond];
1059 end [shape=Msquare];
1060 }
1061 \end{verbatim}
1062 \end{minipage} \hspace{0.05in} \
1063 \parbox[t]{2.0in}{
1064 \ \\
1065 \centerline {
1066 \includegraphics[width=1.9in]{clust1}
1067 }
1068 }
1069 \caption{Process diagram with clusters}
1070 \label{fig:clust1}
1071 \end{figure}
1072 \clearpage
1073
1074 \begin{figure}[p]
1075 \footnotesize
1076 \begin{verbatim}
1077 1:digraph G {
1078 2: size="8,6"; ratio=fill; node[fontsize=24];
1079 3:
1080 4: ciafan->computefan; fan->increment; computefan->fan; stringdup->fatal;
1081 5: main->exit; main->interp_err; main->ciafan; main->fatal; main->malloc;
1082 6: main->strcpy; main->getopt; main->init_index; main->strlen; fan->fatal;
1083 7: fan->ref; fan->interp_err; ciafan->def; fan->free; computefan->stdprintf;
1084 8: computefan->get_sym_fields; fan->exit; fan->malloc; increment->strcmp;
1085 9: computefan->malloc; fan->stdsprintf; fan->strlen; computefan->strcmp;
1086 10: computefan->realloc; computefan->strlen; debug->sfprintf; debug->strcat;
1087 11: stringdup->malloc; fatal->sfprintf; stringdup->strcpy; stringdup->strlen;
1088 12: fatal->exit;
1089 13:
1090 14: subgraph "cluster_error.h" { label="error.h"; interp_err; }
1091 15:
1092 16: subgraph "cluster_sfio.h" { label="sfio.h"; sfprintf; }
1093 17:
1094 18: subgraph "cluster_ciafan.c" { label="ciafan.c"; ciafan; computefan;
1095 19: increment; }
1096 20:
1097 21: subgraph "cluster_util.c" { label="util.c"; stringdup; fatal; debug; }
1098 22:
1099 23: subgraph "cluster_query.h" { label="query.h"; ref; def; }
1100 24:
1101 25: subgraph "cluster_field.h" { get_sym_fields; }
1102 26:
1103 27: subgraph "cluster_stdio.h" { label="stdio.h"; stdprintf; stdsprintf; }
1104 28:
1105 29: subgraph "cluster_<libc.a>" { getopt; }
1106 30:
1107 31: subgraph "cluster_stdlib.h" { label="stdlib.h"; exit; malloc; free; realloc; }
1108 32:
1109 33: subgraph "cluster_main.c" { main; }
1110 34:
1111 35: subgraph "cluster_index.h" { init_index; }
1112 36:
1113 37: subgraph "cluster_string.h" { label="string.h"; strcpy; strlen; strcmp; strcat; }
1114 38:}
1115 \end{verbatim}
1116 \caption{Call graph file}
1117 \label{fig:clust2}
1118 \end{figure}
1119
1120 \begin{figure}[p]
1121 \centerline {
1122 \includegraphics[width=6.5in]{clust2}
1123 }
1124 \caption{Call graph with labeled clusters}
1125 \label{fig:callgraph}
1126 \end{figure}
1127
1128 If the top-level graph has the {\tt compound} attribute set to true,
1129 \dot\ will allow edges connecting nodes and clusters. This is accomplished
1130 by an edge defining an {\tt lhead} or {\tt ltail} attribute. The
1131 value of these attributes must be the name of a cluster containing the
1132 head or tail node, respectively. In this case, the edge is clipped at
1133 the cluster boundary. All other edge attributes, such as {\tt arrowhead}
1134 or {\tt dir}, are applied to the truncated edge. For example,
1135 Figure~\ref{fig:compound} shows a graph using the {\tt compound} attribute
1136 and the resulting diagram.
1137
1138 \begin{figure}[p]
1139 \begin{minipage}[t]{2.25in}
1140 \begin{verbatim}
1141 digraph G {
1142 compound=true;
1143 subgraph cluster0 {
1144 a -> b;
1145 a -> c;
1146 b -> d;
1147 c -> d;
1148 }
1149 subgraph cluster1 {
1150 e -> g;
1151 e -> f;
1152 }
1153 b -> f [lhead=cluster1];
1154 d -> e;
1155 c -> g [ltail=cluster0,
1156 lhead=cluster1];
1157 c -> e [ltail=cluster0];
1158 d -> h;
1159 }
1160 \end{verbatim}
1161 \end{minipage} \hspace{0.5in} \
1162 \parbox[t]{2.0in}{
1163 \ \\
1164 \centerline {
1165 \includegraphics[width=2in]{compound}
1166 }
1167 }
1168 \caption{Graph with edges on clusters}
1169 \label{fig:compound}
1170 \end{figure}
1171
1172 \subsection{Concentrators}
1173 Setting \verb"concentrate=true" on the top-level graph enables
1174 an edge merging technique to reduce clutter in dense layouts.
1175 Edges are merged when they run parallel, have a common endpoint
1176 and have length greater than 1.
1177 A beneficial side-effect in fixed-sized layouts is that removal
1178 of these edges often permits larger, more readable labels.
1179 While concentrators in \dot\ look somewhat like Newbery's
1180 \cite{newbery:concentrators}, they are found by searching
1181 the edges in the layout, not by detecting complete bipartite graphs in
1182 the underlying graph. Thus the \dot\ approach runs much faster
1183 but doesn't collapse as many edges as Newbery's algorithm.
1184
1185 \section{Command Line Options}
1186
1187 By default, \dot\ operates in filter mode,
1188 reading a graph from {\tt stdin}, and
1189 writing the graph on {\tt stdout} in the \DOT\ format with
1190 layout attributes appended.
1191 \dot\ supports a variety of command-line options:
1192
1193 {\tt-T{\it format}} sets the format of the output. Allowed values
1194 for {\it format} are:
1195
1196 \begin{description}
1197 \item[{\tt bmp}] Windows bitmap format.
1198 \item[{\tt canon}]
1199 Prettyprint input; no layout is done.
1200 \item[{\tt dot}]
1201 Attributed \DOT. Prints input with layout information attached as
1202 attributes, cf. Appendix~\ref{sect:output}.
1203 \item[{\tt fig}] FIG output.
1204 \item[{\tt gd}] GD format. This is the internal format used by the GD Graphics
1205 Library. An alternate format is {\tt gd2}.
1206 \item[{\tt gif}] GIF output.
1207 \item[{\tt imap}] Produces map files for server-side image
1208 maps. This can be combined with a graphical form of the output, e.g., using
1209 {\tt -Tgif} or {\tt -Tjpg}, in web pages to attach links to nodes and edges.
1210 \item[{\tt cmapx}] Produces HTML map files for client-side image maps.
1211 \item[{\tt pdf}] Adobe PDF via the Cairo library. We have seen problems when embedding into other documents. Instead, use -Tps2 as described below.
1212 \item[{\tt plain}] Simple, line-based ASCII format. Appendix~\ref{app:plain}
1213 describes this output. An alternate format is {\tt plain-ext}, which
1214 provides port names on the head and tail nodes of edges.
1215 \item[{\tt png}] PNG (Portable Network Graphics) output.
1216 \item[{\tt ps}] PostScript (EPSF) output.
1217 \item[{\tt ps2}] PostScript (EPSF) output with PDF annotations. This output should be distilled into PDF, such as for pdflatex, before being included in
1218 a document. (Use ps2pdf; epstopdf doesn't handle \verb"%%BoundingBox: (atend)".)
1219 \item[{\tt svg}] SVG output. The alternate form {\tt svgz} produces
1220 compressed SVG.
1221 \item[{\tt vrml}] VRML output.
1222 \item[{\tt wbmp}] Wireless BitMap (WBMP) format.
1223 \end{description}
1224
1225 {\tt-G{\it name}={\it value}} sets a graph attribute default value.
1226 Often it is convenient to set size, pagination, and related
1227 values on the command line rather than in the graph file.
1228 The analogous flags \verb"-N" or \verb"-E"
1229 set default node or edge attributes.
1230 Note that file contents override command line arguments.
1231
1232 {\tt-l{\it libfile}} specifies a device-dependent graphics library
1233 file. Multiple libraries may be given. These names are passed to the code
1234 generator at the beginning of output.
1235
1236 {\tt-o{\it outfile}} writes output into file {\it outfile}.
1237
1238 \verb"-v" requests verbose output. In processing large layouts,
1239 the verbose messages may give some estimate of \dot's progress.
1240
1241 \verb"-V" prints the version number and exits.
1242
1243 \section{Miscellaneous}
1244
1245 In the top-level graph heading, a graph may be declared a
1246 {\tt strict digraph} or a {\tt strict graph}. This forbids the creation
1247 of multi-edges, i.e., there can be at most one edge with a given tail
1248 node and head node in the directed case. For undirected graphs,
1249 there can be at most one
1250 edge connected to the same two nodes. Subsequent edge statements using
1251 the same two nodes will identify the edge with the previously defined one
1252 and apply any attributes given in the edge statement.
1253
1254 Nodes, edges and graphs may have a {\tt URL} attribute. In certain
1255 output formats ({\tt ps2}, {\tt imap}, {\tt cmapx}, or {\tt svg}),
1256 this information is integrated in the output
1257 so that nodes, edges and clusters become active links
1258 when displayed with the appropriate tools. Typically, URLs attached to
1259 top-level graphs serve as base URLs, supporting relative URLs on
1260 components. When the output format is {\tt imap}, or {\tt cmapx},
1261 a similar processing
1262 takes place with the {\tt headURL} and {\tt tailURL} attributes.
1263
1264 For certain formats ({\tt ps}, {\tt fig}
1265 or {\tt svg}), {\tt comment} attributes can be used to
1266 embed human-readable notations in the output.
1267
1268 \section{Conclusions}
1269
1270 \dot\ produces pleasing hierarchical drawings and can be
1271 applied in many settings.
1272
1273 Since the basic algorithms of \dot\ work well, we have a good basis for
1274 further research into problems such as methods for drawing large graphs
1275 and on-line (animated) graph drawing.
1276
1277 \section{Acknowledgments}
1278 We thank Phong Vo for his advice
1279 about graph drawing algorithms and programming.
1280 The graph library uses Phong's splay tree dictionary library.
1281 Also, the users of \dag, the predecessor of \dot,
1282 gave us many good suggestions.
1283 Guy Jacobson and Randy Hackbarth reviewed earlier
1284 drafts of this manual, and Emden contributed substantially to the
1285 current revision. John Ellson wrote the generalized polygon
1286 shape and spent considerable effort to make it robust and efficient.
1287 He also wrote the GIF and ISMAP generators and other tools
1288 to bring \graphviz\ to the web.
1289
1290 \clearpage
1291 \bibliography{graphdraw}
1292
1293 \appendix
1294 \clearpage
1295 \section{Principal Node Attributes}
1296 \label{sec:node_attr}
1297 %\begin{table}[p]
1298 \begin{tabular}[t]{|l|l|p{3.0in}|} \hline
1299 Name & Default & Values \\ \hline
1300 %{\tt bottomlabel} & & auxiliary label for nodes of {\tt shape} M* \\
1301 {\tt color} & {\tt black} & node shape color \\
1302 {\tt colorscheme} & X11 & scheme for interpreting color names \\
1303 {\tt comment} & & any string (format-dependent) \\
1304 {\tt distortion} & {\tt 0.0} & node distortion for {\tt shape=polygon} \\
1305 {\tt fillcolor} & {\tt lightgrey/black} & node fill color \\
1306 {\tt fixedsize} & false & label text has no affect on node size \\
1307 {\tt fontcolor} & {\tt black} & type face color \\
1308 {\tt fontname} & {\tt Times-Roman} & font family \\
1309 {\tt fontsize} & {\tt 14} & point size of label \\
1310 {\tt group} & & name of node's horizontal alignment group \\
1311 {\tt height} & {\tt .5} & minimum height in inches \\
1312 {\tt id} & & any string (user-defined output object tags) \\
1313 {\tt image} & & image file name \\
1314 {\tt imagescale} & false & true, width, height, both \\
1315 {\tt label} & node name & any string \\
1316 {\tt labelloc} & c & node label vertical alignment \\
1317 {\tt layer} & overlay range & {\tt all}, {\it id} or {\it id:id}, or a comma-separated
1318 list of the former \\
1319 {\tt margin} & 0.11,0.55 & space around label \\
1320 {\tt nojustify} & false & if true, justify to label, not node \\
1321 {\tt orientation} & {\tt 0.0} & node rotation angle \\
1322 {\tt penwidth} & 1.0 & width of pen for drawing boundaries, in points \\
1323 {\tt peripheries} & {\tt shape-dependent} & number of node boundaries \\
1324 {\tt regular} & false & force polygon to be regular \\
1325 {\tt samplepoints} & 8 or 20 & number vertices to convert circle or ellipse \\
1326 {\tt shape} & {\tt ellipse} & node shape; see Section~\ref{sect:shape} and
1327 Appendix~\ref{app:shapes}\\
1328 % {\tt shapefile} & & (deprecated, shape file)\\
1329 {\tt sides} & {\tt 4} & number of sides for {\tt shape=polygon} \\
1330 {\tt skew} & {\tt 0.0} & skewing of node for {\tt shape=polygon} \\
1331 {\tt style} & & graphics options, e.g. {\tt bold, dotted, filled};
1332 cf. Section~\ref{sect:style} \\
1333 {\tt target} & & if URL is set, determines browser window for URL \\
1334 {\tt tooltip} & label & tooltip annotation \\
1335 %{\tt toplabel} & & auxiliary label for nodes of {\tt shape} M* \\
1336 {\tt URL} & & URL associated with node (format-dependent) \\
1337 {\tt width} & {\tt .75} & minimum width in inches \\
1338 \hline
1339 \end{tabular}
1340 %\caption{Node attributes}
1341 %\label{tab:nattr}
1342 %\end{table}
1343
1344 %\clearpage
1345 \section{Principal Edge Attributes}
1346 \label{sec:edge_attr}
1347 %\begin{table}[p]
1348 {\footnotesize
1349 \begin{tabular}[t]{|l|l|p{3.5in}|} \hline
1350 Name & Default & Values \\ \hline
1351 {\tt arrowhead} & normal & style of arrowhead at head end \\
1352 {\tt arrowsize} & {\tt 1.0} & scaling factor for arrowheads \\
1353 {\tt arrowtail} & normal & style of arrowhead at tail end \\
1354 {\tt color} & {\tt black} & edge stroke color \\
1355 {\tt colorscheme} & X11 & scheme for interpreting color names \\
1356 {\tt comment} & & any string (format-dependent) \\
1357 {\tt constraint} & true & use edge to affect node ranking \\
1358 {\tt decorate} & & if set, draws a line connecting labels with their edges \\
1359 {\tt dir} & {\tt forward} & {\tt forward}, {\tt back}, {\tt both}, or {\tt none} \\
1360 {\tt edgeURL} & & URL attached to non-label part of edge \\
1361 {\tt edgehref} & & synonym for edgeURL \\
1362 {\tt edgetarget} & & if URL is set, determines browser window for URL \\
1363 {\tt edgetooltip} & label & tooltip annotation for non-label part of edge \\
1364 {\tt fontcolor} & {\tt black} & type face color \\
1365 {\tt fontname} & {\tt Times-Roman} & font family \\
1366 {\tt fontsize} & {\tt 14} & point size of label \\
1367 {\tt headclip} & true & if false, edge is not clipped to head node boundary \\
1368 {\tt headhref} & & synonym for headURL \\
1369 {\tt headlabel} & & label placed near head of edge \\
1370 {\tt headport} & & {\tt n,ne,e,se,s,sw,w,nw}\\
1371 {\tt headtarget} & & if headURL is set, determines browser window for URL \\
1372 {\tt headtooltip} & label & tooltip annotation near head of edge \\
1373 {\tt headURL} & & URL attached to head label \\
1374 {\tt href} & & alias for URL \\
1375 {\tt id} & & any string (user-defined output object tags) \\
1376 {\tt label} & & edge label \\
1377 {\tt labelangle} & {\tt -25.0} & angle in degrees which head or tail label
1378 is rotated off edge \\
1379 {\tt labeldistance} & {\tt 1.0} & scaling factor for distance of head or tail label from node \\
1380 {\tt labelfloat} & false & lessen constraints on edge label placement \\
1381 {\tt labelfontcolor} & {\tt black} & type face color for head and tail labels\\
1382 {\tt labelfontname} & {\tt Times-Roman} & font family for head and tail labels\\
1383 {\tt labelfontsize} & {\tt 14} & point size for head and tail labels \\
1384 {\tt labelhref} & & synonym for labelURL \\
1385 {\tt labelURL} & & URL for label, overrides edge URL \\
1386 {\tt labeltarget} & & if URL or labelURL is set, determines browser window for URL \\
1387 {\tt labeltooltip} & label & tooltip annotation near label \\
1388 {\tt layer} & overlay range & {\tt all}, {\it id} or {\it id:id}, or a comma-separated
1389 list of the former\\
1390 {\tt lhead} & & name of cluster to use as head of edge \\
1391 {\tt ltail} & & name of cluster to use as tail of edge \\
1392 {\tt minlen} & {\tt 1} & minimum rank distance between head and tail \\
1393 {\tt penwidth} & 1.0 & width of pen for drawing edge stroke, in points \\
1394 {\tt samehead} & & tag for head node; edge heads with the same tag are merged onto
1395 the same port \\
1396 {\tt sametail} & & tag for tail node; edge tails with the same tag are merged onto
1397 the same port \\
1398 {\tt style} & & graphics options, e.g. {\tt bold, dotted, filled}; cf.
1399 Section~\ref{sect:style} \\
1400 {\tt tailclip} & true & if false, edge is not clipped to tail node boundary \\
1401 {\tt tailhref} & & synonym for tailURL \\
1402 {\tt taillabel} & & label placed near tail of edge \\
1403 {\tt tailport} & & {\tt n,ne,e,se,s,sw,w,nw}\\
1404 {\tt tailtarget} & & if tailURL is set, determines browser window for URL \\
1405 {\tt tailtooltip} & label & tooltip annotation near tail of edge \\
1406 {\tt tailURL} & & URL attached to tail label \\
1407 {\tt target} & & if URL is set, determines browser window for URL \\
1408 {\tt tooltip} & label & tooltip annotation \\
1409 {\tt weight} & {\tt 1} & integer cost of stretching an edge \\
1410 \hline
1411 \end{tabular}
1412 %\caption{Edge attributes}
1413 %\label{tab:eattr}
1414 %\end{table}
1415 }
1416
1417 %\clearpage
1418 \section{Principal Graph Attributes}
1419 \label{sec:graph_attr}
1420
1421 %\begin{table}[p]
1422 {\footnotesize
1423 \begin{tabular}[t]{|l|l|p{3.5in}|} \hline
1424 Name & Default & Values \\ \hline
1425 {\tt aspect} & & controls aspect ratio adjustment \\
1426 {\tt bgcolor} & & background color for drawing, plus initial fill color \\
1427 {\tt center} & false & center drawing on {\tt page} \\
1428 {\tt clusterrank} & {\tt local} & may be {\tt global} or {\tt none} \\
1429 {\tt color} & {\tt black} & for clusters, outline color, and fill color
1430 if {\tt fillcolor} not defined \\
1431 {\tt colorscheme} & X11 & scheme for interpreting color names \\
1432 {\tt comment} & & any string (format-dependent) \\
1433 {\tt compound} & false & allow edges between clusters \\
1434 {\tt concentrate} & false & enables edge concentrators \\
1435 {\tt dpi} & 96 & dots per inch for image output \\
1436 {\tt fillcolor} & {\tt black} & cluster fill color \\
1437 {\tt fontcolor} & {\tt black} & type face color \\
1438 {\tt fontname} & {\tt Times-Roman} & font family \\
1439 {\tt fontnames} & & {\tt svg}, {\tt ps}, {\tt gd} (SVG only) \\
1440 {\tt fontpath} & & list of directories to search for fonts \\
1441 {\tt fontsize} & {\tt 14} & point size of label \\
1442 {\tt id} & & any string (user-defined output object tags) \\
1443 {\tt label} & & any string \\
1444 {\tt labeljust} & centered & "l" and "r" for left- and right-justified
1445 cluster labels, respectively \\
1446 {\tt labelloc} & top & "t" and "b" for top- and bottom-justified cluster
1447 labels, respectively \\
1448 {\tt landscape} & & if true, means orientation=landscape \\
1449 {\tt layers} & & {\it id:id:id...} \\
1450 {\tt layersep} & : & specifies separator character to split {\tt layers} \\
1451 {\tt margin} & {\tt .5} & margin included in {\tt page}, inches \\
1452 {\tt mindist} & {\tt 1.0} & minimum separation between all nodes (not dot)\\
1453 {\tt nodesep} & {\tt .25} & separation between nodes, in inches. \\
1454 {\tt nojustify} & false & if true, justify to label, not graph \\
1455 {\tt ordering} & & if {\tt out} out edge order is preserved \\
1456 {\tt orientation} & {\tt portrait} & if {\tt rotate} is not used and the value
1457 is {\tt landscape}, use landscape orientation \\
1458 {\tt outputorder} & breadthfirst & or nodesfirst, edgesfirst \\
1459 {\tt page} & & unit of pagination, {\it e.g.} {\tt "8.5,11"} \\
1460 {\tt pagedir} & {\tt BL} & traversal order of pages \\
1461 {\tt pencolor} & black & color for drawing cluster boundaries \\
1462 {\tt penwidth} & 1.0 & width of pen for drawing boundaries, in points \\
1463 {\tt peripheries} & 1 & number of cluster boundaries \\
1464 {\tt rank} & & {\tt same}, {\tt min}, {\tt max}, {\tt source} or {\tt sink} \\
1465 {\tt rankdir} & {\tt TB} & {\tt LR} (left to right) or {\tt TB} (top to bottom) \\
1466 {\tt ranksep} & {\tt .75} & separation between ranks, in inches. \\
1467 {\tt ratio} & & approximate aspect ratio desired, {\tt fill} or {\tt auto} \\
1468 minimization \\
1469 {\tt rotate} & & If 90, set orientation to landscape \\
1470 {\tt samplepoints} & {\tt 8} & number of points used to represent ellipses
1471 and circles on output (cf. Appendix~\ref{sect:output} \\
1472 {\tt searchsize} & {\tt 30} & maximum edges with negative cut values to
1473 check when looking for a minimum one during network simplex \\
1474 {\tt size} & & maximum drawing size, in inches \\
1475 {\tt splines} & & draw edges as splines, polylines, lines \\
1476 {\tt style} & & graphics options, e.g. {\tt filled} for clusters \\
1477 {\tt stylesheet} & & pathname or URL to XML style sheet for SVG \\
1478 {\tt target} & & if URL is set, determines browser window for URL \\
1479 {\tt tooltip} & label & tooltip annotation for cluster \\
1480 {\tt truecolor} & & if set, force 24 bit or indexed color in image output \\
1481 {\tt viewport} & & clipping window on output \\
1482 {\tt URL} & & URL associated with graph (format-dependent) \\
1483 \hline
1484 \end{tabular}
1485 %\caption{Graph attributes}
1486 %\label{tab:gattr}
1487 %\end{table}
1488 }
1489
1490 \clearpage
1491 \section{Graph File Grammar}
1492 \label{grammar}
1493
1494 \newcommand{\lopt}{[}
1495 \newcommand{\ropt}{]}
1496 \newcommand{\lgrp}{(}
1497 \newcommand{\rgrp}{)}
1498 \newcommand{\strict}{{\bf strict}}
1499 \newcommand{\graph}{{\bf graph}}
1500 \newcommand{\digraph}{{\bf digraph}}
1501 \newcommand{\node}{{\bf node}}
1502 \newcommand{\edge}{{\bf edge}}
1503 \newcommand{\subgraph}{{\bf subgraph}}
1504
1505 The following is an abstract grammar for the \DOT\ language.
1506 Terminals are shown in bold font and nonterminals in italics.
1507 Literal characters are given in single quotes.
1508 Parentheses \lgrp\ and \rgrp\ indicate grouping when needed.
1509 Square brackets \lopt\ and \ropt\ enclose optional items.
1510 Vertical bars $|$ separate alternatives.
1511
1512 \begin{tabular}{lll}
1513
1514 {\it graph} & $\rightarrow$ & \lopt \strict \ropt\ \lgrp\digraph\ $|$ \graph\rgrp\ {\it id} '\{' {\it stmt-list} '\}' \\
1515
1516 {\it stmt-list} & $\rightarrow$ & \lopt {\it stmt} \lopt';'\ropt\ \lopt {\it stmt-list}\ \ropt\ \ropt \\
1517
1518 {\it stmt} & $\rightarrow$ & {\it attr-stmt} $|$ {\it node-stmt} $|$ {\it edge-stmt} $|$ {\it subgraph} $|$ {\it id} '=' {\it id} \\
1519
1520 {\it attr-stmt} & $\rightarrow$ & \lgrp\graph\ $|$ \node\ $|$ \edge\rgrp\ {\it attr-list} \\
1521
1522 {\it attr-list} & $\rightarrow$ & '[' \lopt {\it a-list} \ropt\ ']' \lopt {\it attr-list}\ropt \\
1523
1524 {\it a-list} & $\rightarrow$ & {\it id} '=' {\it id} \lopt','\ropt\ \lopt {\it a-list}\ropt \\
1525
1526 {\it node-stmt} & $\rightarrow$ & {\it node-id} \lopt{\it attr-list}\ropt \\
1527
1528 {\it node-id} & $\rightarrow$ & {\it id} \lopt {\it port}\ropt \\
1529
1530 {\it port} & $\rightarrow$ & ':' {\it id} \lopt ':' {\it id} \ropt \\
1531
1532 {\it edge-stmt} & $\rightarrow$ & \lgrp{\it node-id} $|$ {\it subgraph}\rgrp\ {\it edgeRHS} \lopt {\it attr-list}\ropt \\
1533
1534 {\it edgeRHS} & $\rightarrow$ & {\it edgeop} \lgrp{\it node-id} $|$ {\it subgraph}\rgrp\ \lopt {\it edgeRHS}\ropt \\
1535
1536 {\it subgraph} & $\rightarrow$ & \lopt \subgraph\ {\it id}\ropt\ '\{' {\it stmt-list} '\}' $|$ \subgraph\ {\it id} \\
1537
1538 \end{tabular}
1539
1540 An {\it id} is any alphanumeric string not beginning with a digit,
1541 but possibly including underscores; or a number; or any quoted
1542 string possibly containing escaped quotes.
1543
1544 An {\it edgeop} is \verb"->" in directed graphs and \verb"--" in
1545 undirected graphs.
1546
1547 The language supports C++-style comments: \verb"/* */" and \verb"//".
1548
1549 Semicolons aid readability but are not required except in the rare case
1550 that a named subgraph with no body immediate precedes an anonymous
1551 subgraph, because under precedence rules this sequence is parsed as
1552 a subgraph with a heading and a body.
1553
1554 Complex attribute values may contain characters, such as commas and
1555 white space, which are used in parsing the \DOT\ language. To avoid getting
1556 a parsing error, such values need to be enclosed in double quotes.
1557
1558 \clearpage
1559 \section{Plain Output File Format ({\tt -Tplain})}
1560 \label{app:plain}
1561 {
1562 \parindent0pt
1563
1564 The ``plain'' output format of \dot\ lists node and edge
1565 information in a simple, line-oriented style which is easy
1566 to parse by front-end components.
1567 All coordinates and lengths are unscaled and in inches.
1568
1569 The first line is:
1570
1571 \hspace{.5in}\verb"graph" {\it scalefactor width height}
1572
1573 The {\it width} and {\it height} values give the width and the height
1574 of the drawing; the lower-left corner of the drawing is at the origin.
1575 The {\it scalefactor} indicates how much to scale all coordinates
1576 in the final drawing.
1577
1578 The next group of lines lists the nodes in the format:
1579
1580 \hspace{.5in}\verb"node" {\it name x y xsize ysize label style shape color fillcolor }
1581
1582 The {\it name} is a unique identifier. If it contains whitespace or
1583 punctuation, it is quoted. The {\it x} and {\it y} values give the coordinates
1584 of the center of the node; the {\it width} and {\it height} give the
1585 width and the height. The remaining parameters provide the node's
1586 {\tt label}, {\tt style}, {\tt shape}, {\tt color} and {\tt fillcolor}
1587 attributes, respectively. If the node does not have a {\tt style} attribute,
1588 {\tt "solid"} is used.
1589
1590 The next group of lines lists edges:
1591
1592 \hspace{.5in}\verb"edge" {\it tail head $n$ $x_1$ $y_1$ $x_2$ $y_2$
1593 $\ldots$ $x_n$ $y_n$ {\rm [} label lx ly {\rm ]} style color }
1594
1595 $n$ is the number of coordinate pairs that follow as B-spline
1596 control points. If the edge is labeled, then the label text and
1597 coordinates are listed next. The edge description is completed by
1598 the edge's {\tt style} and {\tt color}. As with nodes, if a {\tt style} is not
1599 defined, {\tt "solid"} is used.
1600
1601 The last line is always:
1602
1603 \hspace{.5in}\verb"stop"
1604 }
1605
1606 \clearpage
1607 \section{Attributed \DOT\ Format ({\tt -Tdot})}
1608 \label{sect:output}
1609
1610 This is the default output format. It reproduces the input,
1611 along with layout information for the graph. Coordinate values
1612 increase up and to the right. Positions are represented by two
1613 integers separated by a comma, representing the $X$ and $Y$ coordinates
1614 of the location specified in points (1/72 of an inch). A position
1615 refers to the center of its associated object.
1616 Lengths are given in inches.
1617
1618 A {\tt bb} attribute is attached to the graph,
1619 specifying the bounding box of the drawing. If the graph has a label,
1620 its position is specified by the {\tt lp} attribute.
1621
1622 Each node gets {\tt pos}, {\tt width} and {\tt height} attributes.
1623 If the node is a record, the record rectangles are given in the {\tt rects}
1624 attribute. If the node is polygonal and the {\tt vertices}
1625 attribute is defined in the input graph, this attribute contains the
1626 vertices of the node. The number of points produced for circles and ellipses
1627 is governed by the {\tt samplepoints} attribute.
1628
1629 Every edge is assigned a {\tt pos} attribute, which consists of
1630 a list of $3n + 1$ locations. These are B-spline control points:
1631 points $p_0, p_1, p_2, p_3$ are the first Bezier spline,
1632 $p_3, p_4, p_5, p_6$ are the second, etc.
1633 Currently, edge points are listed top-to-bottom (or left-to-right)
1634 regardless of the orientation of the edge. This may change.
1635
1636 In the {\tt pos} attribute, the list of control points might
1637 be preceded by a start point $p_s$ and/or an end point $p_e$. These have the
1638 usual position representation with a {\tt "s,"} or {\tt "e,"}
1639 prefix, respectively. A start point is present if there is an
1640 arrow at $p_0$.
1641 In this case, the arrow is from $p_0$ to $p_s$, where
1642 $p_s$ is actually on the node's boundary. The length and direction
1643 of the arrowhead
1644 is given by the vector $(p_s - p_0)$.
1645 If there is no arrow, $p_0$ is on the node's boundary.
1646 Similarly, the point $p_e$ designates an arrow at the other end of the
1647 edge, connecting to the last spline point.
1648
1649 If the edge has a label, the label position is given in {\tt lp}.
1650
1651 \clearpage
1652 \section{Layers}
1653 {\dot} has a feature for drawing parts of a single diagram on
1654 a sequence of overlapping ``layers.'' Typically the layers are
1655 overhead transparencies. To activate this feature, one must
1656 set the top-level graph's {\tt layers} attribute to a list of identifiers.
1657 A node or edge can then be assigned to list of layers
1658 using its {\tt layer} attribute.
1659 A list of layers is specified as a comma-separated list of ranges, and
1660 a range is either a single layer or has the form {\em id}:{\em id'}, the latter
1661 denoting all layers from {\em id} through {\em id'}.
1662 {\tt all} is a reserved name for all layers (and can be
1663 used at either end of a range, e.g {\tt design:all} or {\tt all:code}).
1664 For example:
1665 \begin{verbatim}
1666 layers = "spec:design:code:debug:ship";
1667 node90 [layer = "code"];
1668 node91 [layer = "design:debug"];
1669 node92 [layer = "all:code"];
1670 node93 [layer = "spec:code,ship"];
1671 node90 -> node91 [layer = "all"];
1672 \end{verbatim}
1673 In this graph, {\tt node91} is in layers {\tt design}, {\tt code}
1674 and {\tt debug}, while {\tt node92} is in layers {\tt spec},
1675 {\tt design} and {\tt code}. {\tt node93} is in layers
1676 layers {\tt spec}, {\tt design}, {\tt code} and {\tt ship}.
1677
1678 In a layered graph, if a node or edge has no layer assignment,
1679 but incident edges or nodes do, then its layer specification
1680 is inferred from these. To change the default so that nodes
1681 and edges with no layer appear on all layers, insert near
1682 the beginning of the graph file:
1683
1684 \begin{verbatim}
1685 node [layer=all];
1686 edge [layer=all];
1687 \end{verbatim}
1688
1689 When PostScript output is selected, the color sequence for layers
1690 is set in the array {\tt layercolorseq}. This array is indexed
1691 starting from 1, and every element must be a 3-element array which can
1692 interpreted as a color coordinate. The adventurous may
1693 learn further from reading {\dot}'s PostScript output.
1694
1695 \clearpage % why does this create a blank page here?
1696 \section{Node Shapes}
1697 \label{app:shapes}
1698 These are the principal node shapes. A more complete description of
1699 node shapes can be found at the web site
1700 \begin{center}
1701 {\tt www.graphviz.org/doc/info/shapes.html}
1702 \end{center}
1703 %\vspace{0.15in}
1704 \begin{center}
1705 \begin{tabular}{cccc}\footnotesize
1706 \includegraphics{box} & \includegraphics{polygon} & \includegraphics{ellipse} & \includegraphics{circle} \\
1707 box & polygon & ellipse & circle \\
1708 \includegraphics{point} & \includegraphics{egg} & \includegraphics{triangle} & \includegraphics{plaintext} \\
1709 point & egg & triangle & plaintext \\
1710 \includegraphics{diamond} & \includegraphics{trapezium} & \includegraphics{parallelogram} & \includegraphics{house} \\
1711 diamond & trapezium & parallelogram & house \\
1712 \includegraphics{hexagon} & \includegraphics{octagon} & \includegraphics{doublecircle} & \includegraphics{doubleoctagon} \\
1713 hexagon & octagon & doublecircle & doubleoctagon \\
1714 \includegraphics{tripleoctagon} & \includegraphics{invtriangle} & \includegraphics{invtrapezium} & \includegraphics{invhouse} \\
1715 tripleoctagon & invtriangle & invtrapezium & invhouse \\
1716 \includegraphics{Mdiamond} & \includegraphics{Msquare} & \includegraphics{Mcircle} & \includegraphics{none} \\
1717 Mdiamond & Msquare & Mcircle & none \\
1718 \includegraphics[scale=0.5]{record} & \includegraphics[scale=0.5]{Mrecord} & & \\
1719 record & Mrecord & & \\
1720 \end{tabular}
1721 \end{center}
1722
1723 \clearpage
1724 \section{Arrowhead Types}
1725 \label{app:arrows}
1726 These are some of the main arrowhead types. A more complete description of
1727 these shapes can be found at the web site
1728 \begin{center}
1729 {\tt www.graphviz.org/doc/info/arrows.html}
1730 \end{center}
1731 \begin{center}
1732 \begin{tabular}{ccc}
1733 \includegraphics{normal} & \includegraphics{dot} & \includegraphics{inv} \\
1734 normal & dot & inv \\
1735 \includegraphics{crow} & \includegraphics{tee} & \includegraphics{vee} \\
1736 crow & tee & vee \\
1737 \includegraphics{diamondarrow} & \includegraphics{no_arrow} & \includegraphics{boxarrow} \\
1738 diamond & none & box \\
1739 \includegraphics{curve} & \includegraphics{icurve} & \\
1740 curve & icurve & \\
1741 \end{tabular}
1742 \end{center}
1743 Arrowhead descriptions support a simple grammar to allow more complex, derived shapes,
1744 such as the examples below.
1745 \begin{center}
1746 \begin{tabular}{ccc}
1747 \includegraphics{odot} & \includegraphics{invdot} & \includegraphics{invodot} \\
1748 odot & invdot & invodot \\
1749 \end{tabular}
1750 \end{center}
1751 The web page cited above describes this grammar in detail.
1752
1753 \clearpage
1754 \section{Color Names}
1755 \label{app:colors}
1756 Here are some basic color names. More information about colors
1757 can be found at
1758 \begin{center}
1759 {\tt www.graphviz.org/doc/info/colors.html} \\
1760 {\tt www.graphviz.org/doc/info/attrs.html\#k:color}
1761 \end{center}
1762 {\footnotesize
1763 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}llll}
1764 {\bf Whites} & {\bf Reds} & {\bf Yellows} & turquoise[1-4] \cr
1765 antiquewhite[1-4] & coral[1-4] & darkgoldenrod[1-4] \cr
1766 azure[1-4] & crimson & gold[1-4] & {\bf Blues} \cr
1767 bisque[1-4] & darksalmon & goldenrod[1-4] & aliceblue \cr
1768 blanchedalmond & deeppink[1-4] & greenyellow & blue[1-4] \cr
1769 cornsilk[1-4] & firebrick[1-4] & lightgoldenrod[1-4] & blueviolet \cr
1770 floralwhite & hotpink[1-4] & lightgoldenrodyellow & cadetblue[1-4] \cr
1771 gainsboro & indianred[1-4] & lightyellow[1-4] & cornflowerblue \cr
1772 ghostwhite & lightpink[1-4] & palegoldenrod & darkslateblue \cr
1773 honeydew[1-4] & lightsalmon[1-4] & yellow[1-4] & deepskyblue[1-4] \cr
1774 ivory[1-4] & maroon[1-4] & yellowgreen & dodgerblue[1-4] \cr
1775 lavender & mediumvioletred & & indigo \cr
1776 lavenderblush[1-4] & orangered[1-4] & {\bf Greens} & lightblue[1-4] \cr
1777 lemonchiffon[1-4] & palevioletred[1-4] & chartreuse[1-4] & lightskyblue[1-4] \cr
1778 linen & pink[1-4] & darkgreen & lightslateblue[1-4] \cr
1779 mintcream & red[1-4] & darkolivegreen[1-4] & mediumblue \cr
1780 mistyrose[1-4] & salmon[1-4] & darkseagreen[1-4] & mediumslateblue \cr
1781 moccasin & tomato[1-4] & forestgreen & midnightblue \cr
1782 navajowhite[1-4] & violetred[1-4] & green[1-4] & navy \cr
1783 oldlace & & greenyellow & navyblue \cr
1784 papayawhip & {\bf Browns} & lawngreen & powderblue \cr
1785 peachpuff[1-4] & beige & lightseagreen & royalblue[1-4] \cr
1786 seashell[1-4] & brown[1-4] & limegreen & skyblue[1-4] \cr
1787 snow[1-4] & burlywood[1-4] & mediumseagreen & slateblue[1-4] \cr
1788 thistle[1-4] & chocolate[1-4] & mediumspringgreen & steelblue[1-4] \cr
1789 wheat[1-4] & darkkhaki & mintcream \cr
1790 white & khaki[1-4] & olivedrab[1-4] & {\bf Magentas} \cr
1791 whitesmoke & peru & palegreen[1-4] & blueviolet \cr
1792 & rosybrown[1-4] & seagreen[1-4] & darkorchid[1-4] \cr
1793 {\bf Greys} & saddlebrown & springgreen[1-4] & darkviolet \cr
1794 darkslategray[1-4] & sandybrown & yellowgreen & magenta[1-4] \cr
1795 dimgray & sienna[1-4] & & mediumorchid[1-4] \cr
1796 gray & tan[1-4] & {\bf Cyans} & mediumpurple[1-4] \cr
1797 gray[0-100] & & aquamarine[1-4] & mediumvioletred \cr
1798 lightgray & {\bf Oranges} & cyan[1-4] & orchid[1-4] \cr
1799 lightslategray & darkorange[1-4] & darkturquoise & palevioletred[1-4] \cr
1800 slategray[1-4] & orange[1-4] & lightcyan[1-4] & plum[1-4] \cr
1801 & orangered[1-4] & mediumaquamarine & purple[1-4] \cr
1802 {\bf Blacks} & & mediumturquoise & violet \cr
1803 black & & paleturquoise[1-4] & violetred[1-4] \cr
1804 \end{tabular*}
1805 }
1806
1807 %\tableofcontents
1808 %\coversheet
1809 \end{document}
1810 %
1811 %END