The NETDRAW Procedure

## Layout of the Network

The network layout is determined in two stages. First, the precedence relationships are used to determine the positions of the nodes, which are then used to determine a routing of the arcs. The positions of the nodes and arcs are identified by specifying their X and Y coordinates in a grid. Figure 5.7 shows a sample grid and explains some of the conventions followed by PROC NETDRAW in determining the node and arc layout. This notation will be useful in later sections that describe the Layout data set and how you can control the layout of the diagram. The asterisks in the figure represent possible positions for the nodes of the network. The arcs are routed between the possible node positions. For example, node `A` has coordinates (1,3) and node `B` has coordinates (2,1). The arc connecting them has two turning points and is completely determined by the two pairs of coordinates (1.5, 3) and (1.5, 1) ; here, X=1.5 implies that the position is midway between the X coordinates 1 and 2. Figure 5.7: Sample Grid and Coordinates for Node and Arc Layout

PROC NETDRAW sets X=1 for all nodes with no predecessors; the X coordinates for the other nodes are determined so that each node is placed to the immediate right of all its predecessors; in other words, no node will appear to the left of any of its predecessors or to the right of any of its successors in the network diagram. The nodes are placed in topological order: a node is placed only after all its predecessors have been placed. Thus, the node-placement algorithm requires that there should be no cycles in the network. The Y coordinates of the nodes are determined by the procedure using several heuristics designed to produce a reasonable compact diagram of the network. To draw a network that has cycles, use the BREAKCYCLE option, or you can specify the node coordinates or an ALIGN= variable to circumvent the requirement of a topological ordering of the nodes (see the second part of Example 5.12.

Note that the X and Y coordinates fix only a relative positioning of the nodes and arcs. The actual distance between two nodes, the width and height of each node, and so on can be controlled by specifying desired values for the options that control the format of the display, namely, BOXHT=, BOXWIDTH=, and so on. See the "Format of the Display" section for details on these options.

By default, the procedure routes the arcs using a simple heuristic that uses, at most, four turning points: the arc leaves the predecessor node from its right edge, turns up or down according to whether the successor is above or below the current node position, then tracks horizontally across to the vertical corridor just before the successor node, and then tracks in a vertical direction to meet the successor node. For example, see the tracking of the arc connecting nodes `C` and `D` in Figure 5.7.

For networks that include some nonstandard precedence constraints, the arcs may be drawn from and to the appropriate edges of the nodes, depending on the type of the constraint.

The default routing of the arcs may lead to an unbalanced diagram with too many arcs in one section and too few in another. The DP option in the ACTNET statement causes the procedure to use a dynamic programming algorithm to route the arcs. This algorithm tries to route the arcs between the nodes so that not too many arcs pass through any interval between two nodes. The procedure sets the maximum number of arcs that are allowed to be routed along any corridor to be equal to the maximum number of successors for any node. The HTRACKS= and VTRACKS= options enable you to set these maximum values: HTRACKS specifies the maximum number of arcs that are allowed to pass horizontally through any point while VTRACKS specifies the same for arcs in the vertical direction. See Example 5.7 for an illustration of the HTRACKS= option.

The layout of the network for time-scaled and zoned network diagrams is discussed in the "Time-Scaled Network Diagrams" section and the "Zoned Network Diagrams" section, respectively. The "Organizational Charts or Tree Diagrams" section describes the layout of the diagram when the TREE option is specified.