DAG(1)

NAME
dag - preprocessor for DAGs and other directed graphs

SYNOPSIS
dag [ -Ttype ] [ -pwidthxheight [ ,marginwidth [ xmarginheight ] ] ] [ -O ] [ -l ] [ files ]

DESCRIPTION
Dag is a pic(1) or Postscript preprocessor for drawing directed graphs. It works well on directed acyclic graphs and other graphs that can be drawn as a hierarchy. dag selects coordinates for the nodes of the graph and creates a picture. Input graphs are surrounded by the troff `commands' .GS and .GE. The graph contains nodes, edges, and optional control statements. Statements are semicolon terminated. Here is a brief summary:

edge from tail to head0 edge-items, to head1 edge-items, to head2 edge-items... : creates edges from the tail node to the head nodes (or node). Nodes are implicitly created if they do not already exist. edge-items (which apply to the edge just made, as described below) and the noisewords edge, from, and to are optional. Node names may be quoted to avoid conflicting with keywords.

ordered tail head0 head1 head2... : makes edges and also constrains the left-to-right order of the head nodes and keeps them on the same rank. May contain noisewords and edge-items.

path node0 node1 node2...: creates a path of edges. May contain noisewords and edge-items.

backedge tail head0 head1 head2...: creates edges that point backward (up or left).

backpath node0 node1 node2...: makes a path of backedges.

draw nodes node-items: Changes default definition for all nodes subsequently created. node-items are: as shape (standard shapes are Box, Circle, Ellipse, Diamond, Square, and Plaintext), label string, pointsize n, width n, height n, color string. Dimensions are in inches. color only works with PostScript and should evaluate to an HSB triple.

draw nodelist node-items: controls drawing (shapes, labels, etc.) of nodes in the list.

draw edges edge-items: Changes default definition of edges subsequently created. edge-items are: dotted, dashed, solid, or invis, label string, weight n, color string, pointsize n.

minimum rank nodelist: constrains nodes to be on the topmost rank (or leftmost if drawn with .GR).

maximum rank nodelist: bottommost or rightmost rank.

same rank nodelist: constrains nodes to be placed on the same rank.

separate ranks n equally or exactly: sets separation between ranks. exactly means rank separation is fixed. equally means that all ranks have the same separation.

The -O option requests ``optimal'' node placement. This makes slightly better layouts, but is only practical for graphs of a few dozen nodes.

Output languages other than pic are requested with -T: -Tps for PostScript, -Tsimple for a simple format similar to that of the Ninth Edition Unix graphdraw editor, and -Tcip for a simplified form of pic code that can be read by the obsolescent cip editor. PostScript drawings are paginated by giving the -p option to set page dimensions. Default margins are one-half inch. Although the margins can be set to zero, Laserwriters have hard margins that prevent making seamless mosaics. The -p option replaces the Poster program from CIA, which is inefficient for large drawings because of quadratic behavior.

The -l option disables automatic loading of the dag graphics library.

A graph is drawn with left-to-right edges by using .GR instead of .GS. The maximum height and width of the drawing may be given on the .GS/.GR line. The optional keyword fill at the end of this line makes dag adjust node positions to fill the bounding box. In-line graphics code such as pic or PostScript macros may be defined in a block between .PS and .PE.

If dag is installed under EXPTOOLS, it uses the standard TOOLS environment variable to find its libraries.

EXAMPLE
.GS 6 8 fill
a b c;
path a x y;
draw nodes as Box;
a z label "hi" weight 1000;
draw edges dashed;
b x;
same rank b x;
.GE

BUGS
troff doesn't have dotted or dashed splines. Use PostScript.

dag doesn't keep edge labels from accidentally overlapping.

SEE ALSO
E. R. Gansner, S. C. North, K. P. Vo, "DAG — A Graph Drawing Program," TM 59554-871019-04TM.