Time-and Cost-Optimal Parallel Algorithms for the Dominance and Visibility Graphs *

The compaction step of integrated circuit design motivates associating several kinds of graphs with a collection of non-overlapping rectangles in the plane. These graphs are intended to capture various visibility relations amongst the rectangles in the collection. The contribution of this paper is to propose time- and cost-optimal algorithms to construct two such graphs, namely, the dominance graph (DG, for short) and the visibility graph (VG, for short). Specifically, we show that with a collection of n non-overlapping rectangles as input, both these structures can be constructed in 0(log n) time using n processors in the CREW model.


INTRODUCTION
Two important design methodologies central to the fabrication of integrated circuits are symbolic layout and compaction.The symbolic layout involves representing a mask layout using symbols and languages to manipulate these symbols; compaction changes the geometry of the topological design to produce a smaller layout while enforcing the design rules and constraints [10,13].Masks used in the process of integrated circuit layout design are usually represented by a set of rectangles in two dimensions, with edges parallel to the axes (henceforth referred to as iso-oriented) 10,11 ].
As it turns out, most of the steps in the compaction process are simplified by using a symbolic description of the layout.It is quite natural, therefore, to express the compaction problem as a problem involving a collection *Work supported in part by NASA under grant NCC1-99 and by the NSF under grant CCR-9407180; (C)  1994 IEEE.Reprinted with permis- sion from Proceedings of VLSI Design'94, Calcutta, India, January 1994 " Address for Correspondence: Prof. Stephan Olariu, Department of Computer Science, Old Dominion University, Norfolk, VA 23529- 0162, email: olariu@cs.odu.edu,Phone: (804) 683-4417, FAX: (804) 683-4900 of iso-oriented, non-overlapping, rectangles in the plane.For simplicity reasons the compaction process is one- dimensional, i.e. the components are moved in the x-direction or y-direction only, or two-dimensional where in a single step selected components are moved in both directions [12,14].Typically, the compaction process is based on the notion of constraint graph (CG, for short).Each vertex of the constraint graph corresponds to a rectangle or to a group of electrically equivalent ele- ments; the edges of the constraint graph correspond to the design constraints that must be satisfied by the circuit [8, 12, 14].
However, in general the constraint graph is rather complicated, with many extraneous edges [14].From a computational standpoint [5] one is motivated to inves- tigate properties of simpler graphs that provide useful heuristic solutions to a good number of special cases of compaction.An important such graph is the visibility graph (VG, for short) studied by several workers [5, 6,  12].Consider a collection of iso-oriented, non-overlap- ping, rectangles in the plane.Two rectangles R and R' are said to be visible if there exists a horizontal line intersecting R and R' and not intersecting any other rectangle that lies between R and R'.The visibility graph has the set of rectangles as its vertices, with two vertices joined by an edge if and only if the corresponding rectangles are visible.
In this work we shall also define a subgraph of the visibility graph that we refer to as the dominance graph (DG, for short).Consider, again, a collection of iso- oriented, non-overlapping, rectangles in the plane.We say that a rectangle A is above rectangle B if some points in A and B share the same x-coordinate with the point in A having a larger y-coordinate.A rectangle A is directly above B if A is above B and no rectangle C is such that A is above C, and C is above B. The dominance graph of a collection of non-overlapping rectangles is "a directed graph whose vertices are precisely the rectangles in the collection; two vertices u and v are linked by a directed edge (u, v) when the rectangle corresponding to u is directly above the rectangle corresponding to v. It is easy to see that the notion of direct aboveness captures the intuitive idea that for compaction purposes we only need consider rectangles that are "neighbors" in the sense that no other rectangles lie between them.It is not hard to see that the dominance, visibility, and constraint graphs are related by DG C VG C CG.
In this paper we assume the Parallel Random Access Machine model which consists of synchronous proces- sors, each having access to a common memory.At each step, every processor performs the same instruction, with a number of processors masked out.In a Concurrent Read Exclusive Write PRAM model (CREW, for short), several processors may simultaneously read the same memory location, but exclusive access is used for writ- ing.The interested reader is referred to [7] for a more detailed discussion on the CREW model.The cost of a parallel algorithm [7] is taken to be the product of its running time and the number of processors used.If the cost of a parallel algorithm matches the sequential lower bound for the given problem, the parallel algorithm is termed cost-optimal.A parallel algorithm is termed time-optimal within a given computational model is no other parallel algorithm solving the same problem runs faster in that model.
The main contribution of this paper is to provide time- and cost-optimal algorithms for the problems of con- structing the dominance and visibility graphs of a col- lection of n iso-oriented, non-overlapping, rectangles in the plane.Our first result is to show that the problem of constructing the dominance graph has a lower bound of 12(n log n) by reducing the ELEMENT UNIQUENESS [4] problem to it.Next, we derive time-lower bounds for the problems of computing the dominance and visibility graphs in the CREW model.Specifically, we show that any parallel algorithm solving these problems must take f(log n) time in the CREW even if an infinite number of processors and memory cells are used.Finally, we propose time-and cost-optimal algorithms to construct the dominance and visibility graphs running in 0(log n) time and using O(n) processors in the CREW model of computation.
The remainder of this work is organized as follows" Section 2 presents our lower bounds; Section 3 presents the details of our time-optimal algorithm to construct the dominance graph; Section 4 discusses the details of the proposed time-optimal algorithm for the visibility graph; finally, Section 5 summarizes the results and poses some open problems.

LOWER BOUNDS
The purpose of this section is to provide lower bounds that establish both the time-and cost-optimality of our algorithms in the CREW model of computation.
We first show that any algorithm that correctly con- structs the domination graph of a collection of n non- overlapping rectangles in the plane must perform at least (n log n) operations.Our arguments rely on a well- known lower bound for the following classic problem.
ELEMENT UNIQUENESS: Given n real numbers x1, x 2 x,,, decide whether any two of them are equal.Proposition 2.1.[4] ELEMENT UNIQUENESS has a lower bound of (n log n) in the algebraic tree model of computation.
[--] Lemma 2.2.The problem of constructing the domina- tion graph of a collection of n non-overlapping rect- angles in the plane has a lower bound of I(n log n) in the algebraic decision-tree model.
Proof.Assume that the input to the ELEMENT UNIQUENESS problem is a set x 1, x 2 x of real numbers.Construct a family R1, R2 Rn of n degen- erate rectangles in the plane by letting every R be specified by its lower-left and upper-right comers both defined as (x i, i).In other words, every rectangle R reduces to the point (x i, i) in the plane.Notice that by construction the rectangles are non-overlapping.Now consider the dominance graph corresponding to this family of rectangles: by scanning the degrees of vertices of this graph we find out in O(n) time whether any two of the real numbers x 1, x2 x are equal.The conclusion follows from Proposition 2.1.
Next, we note that Schlag et al. [12] have established a similar lower bound for the problem of constructing the visibility graph of n rectangles in the plane.Specifically, a variant of the following result was established in [12].
Proposition 2.3.The problem of constructing the vis- ibility graph of a collection of n non-overlapping rect- angles in the plane has a lower bound of 2(n log n) in the algebraic decision-tree model.
In fact, Proposition 2.3 can also be proved directly in a way essentially similar to the proof of Lemma 2.2.
Our next goal is to establish a time lower bound for the tasks of constructing the dominance and visibility graphs in the CREW model.For this purpose, we rely on a fundamental result of Cook et al. [3].To make this paper self-contained, we define the problem and state the relevant result from [3].
b n, compute their logical OR.
Proposition 2.4.[3] OR has a time lower bound of (log n) on the CREW, regardless of the number of processors and memory cells used.Theorem 2.5.The problem of constructing the domi- nance graph of a set of n non-overlapping rectangles in the plane has a lower bound of f(log n) on the CREW, regardless of the number of processors and memory cells used.
Proof.To establish the lower bound, we only need show that the solution to the dominance graph problem for n iso-oriented, non-overlapping, rectangles in the plane yields a solution to the OR problem.Let b 1, b2 bn be the input to the OR problem.We construct a collection R o, R R of n + 1 non-overlapping rectangles.We specify each rectangle by an ordered pair consisting of the coordinates of its lower-left and upper-fight comers, respectively.More precisely, we set: R o ((1, n + 1),(n + 2, n + 1.5)); for all (1 <--<n), R ((i, n-+ 1), (i + 2, n-+ 1.5)), whenever b 0; R ((i, n-+ 1), (i + 1, n-+ 1.5)), whenever bi--1.) Clearly the answer to the OR problem is 0 if and only if the out-degree of the vertex corresponding to R o is 1.Therefore, once the dominance graph is available, one can find the answer to OR in O(1) time.By virtue of Proposition 2.4, any algorithm that computes the domi- nance graph must take f(log n) time in the worst case.This completes the proof of the theorem.Theorem 2.6.The problem of constructing the visibility graph of a set of n iso-oriented, non-overlapping rect-

R01 FIGURE
Illustrating the lower bound for dominance graph.
angles in the plane has a lower bound of l(log n) on the CREW, regardless of the number of processors and memory cells used.
Proof.The claim will be established by showing that a solution of the visibility graph problem implies a solu- tion for OR.Let the bit string b 1, b 2 b,, be the input to the OR problem.Corresponding to this input, we construct a collection of n + 2 iso-oriented, non- overlapping, rectangles R o, R R n, R+ 1.We specify each rectangle by an ordered pair consisting of the coordinates of its lower-left and upper-fight comers, respectively.More precisely, we set: R o ((0, 0), (0.5, 2)), R,,+ ((n + 1, 0), (n + 1.5, 2)) and for alli(1 --<i--<n) R ((i, 0), (i + 0.5, 3)), whenever b 1, and R ((i, 0), (i + 0.5, 1)), whenever b O. Rn+ are visible.Thus, once the visibility graph is available, one can find the answer to OR in O(1) time.Therefore, Proposition 2.4 guarantees that any algorithm that constructs the visibility graph must take 12(log n) time in the worst case.D. BHAGAVATHI, H. GURLA, S. OLARIU, J. L. SCHWlNG AND J. ZHANG 3

CONSTRUCTING THE DOMINANCE GRAPH
The purpose of this section is to exhibit a time-and cost-optimal algorithm to construct the dominance graph of a set of n iso-oriented, non-overlapping, rectangles R 1, R e R in the plane.For convenience, we assume that every rectangle R is represented by a set of four edges, R { li, ri, ti, bi} with and r standing for the left and right vertical edges respectively; similarly, we let and b denote the top and bottom horizontal edges, respectively.
Every edge is represented by its two endpoints.To avoid tedious and inconsequential housekeeping details, we assume that all rectangles have distinct x and y coordi- nates.
Draw from each endpoint of a horizontal edge (resp.bi) (1 < <--n) upward (resp.downward) pointing half-lines.Each of these half-lines terminates when it encounters the horizontal edge of another rectangle, or continues to infinity.It is customary to refer to these half-lines as trapezoidal lines.What results is a partition of the plane into rectangular regions (bounded or un- bounded).Such a decomposition is termed a trapezoidal decomposition (see Figure 3).Furthermore, it is fairly easy to see that the number of trapezoids in the decom- position is O(n).
Note that every bounded trapezoid T has its horizontal edges determined by the horizontal edges of two rect- angles in our collection; the vertical edges are either trapezoidal lines or combinations of trapezoidal lines and the vertical edge of some rectangle (refer to Figure 3 for an illustration).As we are about to point out, the trapezoidal decomposition is closely related to the notion of direct aboveness.Lemma 3.1.Let R and R be rectangles such that b has a larger y-coordinate than tu.Rv is directly above R if, and only if, there exists a trapezoid determined by bv, tu and two trapezoidal lines originating at the endpoints of b and u.
Proof.To begin, note that if R is directly above R then there exists a trapezoid satisfying the requirements of the lemma (refer to Figure 4).
Conversely, suppose that the trapezoidal region con- sisting of bv, tu and two trapezoidal lines originating at the endpoints of bv and exists.It is easy to see that no other rectangle in the collection can be between R and R u, and the conclusion follows.
7q Lemma 3.1 motivates the following approach to con- structing the dominance graph.Begin by performing the trapezoidal decomposition of the plane and assign one processor to each corner of every rectangle in the collection.Every processor is responsible for detecting a trapezoid satisfying the requirements of Lemma 3.1.The dominance graph DG will be returned by its adjacency lists structure: that is, for every vertex u of DG we return a linked list that contains all the vertices v for which (u, v) is an edge in DG.The details are spelled out as follows.
Algorithm Construct_Dominance_Graph; {Input: a collection R 1, R e Rn of n iso-oriented non-overlap- ping rectangles in the plane; Output: the corresponding dominance graph DG repre- sented by its adjacency lists; } Step 1. Sort all the edges (1 < -< n) in increasing order of their x-coordinates; R R FIGURE 3 A trapezoidal decomposition.FIGURE 4 The trapezoid T satisfies the conditions of Lemma 3.1.
Step 2. Divide the plane into trapezoids by using the optimal parallel trapezoidal decomposition of [1]; Step 3. Assign one processor to each corner of every rectangle in the collection; for (1 -< -< n) let P1 i, P2 i, P3 i, P4 be the processors assigned to R 1, with P1 assigned to the upper-left corner and proceeding counter- clockwise (refer to Figure 5); Step 4. For all i, j (1 -< -< n; 1 -< j -< 4) in parallel processor eji identifies the following trapezoidal line segments: aj starting from the point on which eji is assigned and pointing upwards (downwards); cj the nearest vertical line segment to the right of aj and parallel to aji; bj and d the two horizontal line segments which bound a' and c (see Figure 5 for an illustration); Step 5.For all i, j (1 <-<-n; <-j <-4) processor eji marks itself active if the rectangular region determined by aj i, bj i, cj i, and d satisfies the conditions of Lemma a ill 11 Cl a2 ,_i 3.1; otherwise, pi marks itself inactive and will never be active again; Step 6.Every active processor pji records (s, t) in its own memory, whenever rectangle R is above rectangle Rt; Step 7. Sort the ordered pairs (s, t) produced in Step 6 by their first component; Step 8.In the sorted list mark the first element in every group of ordered pairs having the same first component; what results are the adjacency lists of the dominance graph.
To summarize our findings we state the following result.
Theorem 3.2.The dominance graph corresponding to a collection of n iso-oriented, non-overlapping, rectangles in the plane can be constructed in O(log n) time using O(n) processors in the CREW.Furthermore, this is both time-and cost-optimal in this model of computation.
Proof.The correctness follows directly from Lemma 3.1.We turn our attention to the complexity.First, we note that since no write conflicts arise, the computation can be performed in the CREW model.

Notice that
Step takes O(log n) time using O(n)   processors if we use Cole's sorting algorithm [5].Next, Step 2 uses the algorithm in running in O(log n) time and using O(n) processors in the CREW model.Step 3 involves a simple assignment operation, and thus re- quires O(1) time.Note that in Step 4 every processor p.i takes O(1) time to determine the lines aj i, b i, Cjl, and dj'.
To clarify this last point, note that aj', b', c , and d belong to the same trapezoid in the collection and so the search of Step 4 can be performed in constant time.
Furthermore, once this information is known, pi marks itself active only if these lines satisfy the conditions of Lemma 3.1: this is done in O(1) time; Further, Step 7 can be implemented in O(log n) time with O(n) processors by using Cole's sorting algorithm.Finally, Step 8 can be implemented in O(1) time with O(n) processors in the obvious way.By Lemma 2.2 our algorithm is cost- optimal; by Theorem 2.5 the algorithm is also time- optimal.This completes the proof of Theorem 3.2. []4 CONSTRUCTING THE VISIBILITY GRAPH Consider, again, a collection {R1, R 2 R,,} of n iso-oriented, non-overlapping, rectangles in the plane.
For the purpose of constructing the visibility graph, it is convenient to abstract rectangles as vertical line seg- ments as described below.In this context, the compaction is referred to as "stick" compaction [5,14].
Specifically, from the collection we obtain a collection Z= {sl, s2 sn} of n disjoint vertical line segments in the plane, such that segment s corresponds to the leftmost vertical edge of rectangle R i.We say that a pair s i, sy of such segments is a visible pair (or, simply, that they see each other [5]) if there exists a horizontal line intersecting si and sy and not intersecting any other line segment s k that lies between s and s (see Figure 6).It is not hard to see that the visibility graph of the original set of rectangles is precisely the visibility graph of the resulting collection of vertical line segments.For every such line segment si (1 <-<-n) we let (x i, ti) and (x i, bi) denote its top and bottom endpoints, respectively.To avoid inconsequential and tedious housekeeping details, we assume that all segments have distinct x and y coordinates.As noted in [5,12] this can always be done without any loss of generality.
Draw from each endpoint of every segment right and left-pointing half-lines.Each of these half-lines termi- nates when it encounters another vertical segment in the collection, or continues to infinity.What results is a trapezoidal decomposition of the plane (refer to Figure 7).It is easy to confirm that every bounded trapezoid T has its horizontal edges determined by trapezoidal lines; the vertical edges correspond to sub-segments of two + m mmm  vertical segments in our collection.As we are about to point out, the trapezoidal decomposition is closely re- lated to the notion of visibility among vertical segments in the plane.Lemma 4.1.Let s and s be arbitrary vertical segments.The segments s and s see each other if, and only if, there exists a trapezoid T whose vertical edges are sub- segments of s and s.
Proof.To begin, note that if s and sy see each other, then the existence of a trapezoid satisfying the requirements of the lemma follows directly from the definition.Conversely, suppose that there exists a trapezoid T satisfying the conditions of the lemma.It is easy to see that no other vertical line segment can be between s and s, and the conclusion follows.Lemma 4.1 motivates the following approach to con- structing the set of all visible pairs: perform the trapezoi- dal decomposition of the plane and then assign one processor to each corner of every trapezoid in the decomposition.Every processor is responsible for detect- ing whether the trapezoid it has been assigned to is bounded i.e. satisfies the requirements of Lemma 4.1.The visibility graph will be returned by its adjacency lists.The details are spelled out as follows.
Algorithm Construct_Visibility_Graph; (Input: a collection S {s, s2 sn} of n vertical line segments in the plane; Output: the corresponding visibility graph represented by adjacency lists; } Step 1. Sort all the vertical line segments in increasing order of their x-coordinates; Step 2. Perform a trapezoidal decomposition of the plane by using the algorithm of [1]; Step 3. Assign one processor to each comer of every trapezoid formed in this way; for (1 -< -< n) let Tg be such a trapezoid and let P1 i, P2 i, P3 i, P4 be the processors assigned to T i, with Pig assigned to the upper-left comer and proceeding counter-clockwise (see Figure 8); Step 7. Sort the ordered pairs (p, q produced in Step 6 by their first component.
Step $.In the sorted list mark the first element in every group of ordered pairs having the same first component; what results are the adjacency lists of the visibility graph.
To summarize our findings we state the following result.
Theorem 4.2.The visibility graph of a collection of n disjoint vertical line segments in the plane can be constructed in O(log n) time using O(n) processors in the CREW model of computation.
Proof.The correctness follows directly from Lemma 4.1.Therefore, we turn our attention to the complexity.First, we note that since no write conflicts arise, the computation can be performed in the CREW model.
Step 4. For all i, j (1 < < n; 1 -< j -< 4) in parallel processor eji identifies the following trapezoidal line segments: aj starting from the point on which pji is assigned and pointing right (left); cj the nearest trapezoidal line below aj and parallel to.aji b and d .i the two vertical line segments which .J bound a and c (see Figure 8 for an illustration); Step 5.For all i, j (1 --< <-n; 1 -< -< 4) processor pji marks itself active if the rectangular region determined by a/, bj g, cj i, and d. is bounded (i.e.b/ and dj both .J exist); otherwise, P/marks itself inactive and will never be active again; Step 6.Every active processor pi records (p, q) in its own memory, with Sp bj and Sq di; To begin, we note that the number of trapezoids in the decomposition is linear in the number of segments 11 ].
Step 1 takes O(log n) time using O(n) processors if we use Cole's sorting algorithm.Next, Step 2 uses the algorithm in [1] running in O(log n) time and using O(n) processors in the CREW model.
Step 3 only involves assignments and takes O(1) time.Note that in Step 4   every processor pi takes O(1) time to determine aj i, b i, cj g, and dj since the required information is stored in one trapezoid in the decomposition; once this information is known, pji marks itself active only if the corresponding trapezoid is bounded: this is done in O(1) time; finally, Steps 7 and 8 can be implemented in O(log n) time with O(n) processors by using Cole's sorting algorithm.
Theorem 4.2, Proposition 2.3, and Theorem 2.6 com- bined imply the following result.Theorem 4.3.Consider a collection of n iso-oriented, non-overlapping, rectangles R, R 2 Rn in the plane.
The corresponding visibility graph can be constructed in O (log n time using O (n) processors in the CREW.Furthermore, this is both time-and cost-optimal in this model of computation.

CONCLUDING REMARKS
In this paper we presented time-and cost-optimal paral- lel algorithms to construct two special kinds of graphs motivated by, and finding applications to, the compaction step of integrated circuit design.Specifically, we have shown that with a family of n iso-oriented, non-overlapping rectangles in the plane, both the dominance and the visibility graphs can be constructed in O(log n) time with O(n) processors in the CREW model of computation.

(Figure 2
illustrates this construction for the input sequence b 0, b 2 0, b 3 1, b 4 1, b 5 0.) Clearly the solution to the OR problem is 0 if and only if R o and

FIGURE 2
FIGURE 2 Illustrating the lower bound for visibility graph.

FIGURE 7
FIGURE 7The trapezoidal decomposition of line segments.

FIGURE 6 A
FIGURE 6 A collection of vertical line segments; segments and sj see each other.