Finding shortest non-crossing rectilinear paths in plane regions

Report 2 Downloads 95 Views
F i n d i n g Shortest N o n - C r o s s i n g R e c t i l i n e a r Paths in Plane Regions Jun-ya Takahashi, Hitoshi Suzuki and Takao Nishizeki Graduate School of Information Sciences Tohoku University Sendai 980, Japan e-mail: j unya~nishizeld.ecei.t ohoku.ac.j p Abstract. Let A be a plane region which is bounded by an outer rectangle and an inner one and has r rectangular obstacles inside the region. Let k terminal pairs lie on the outer and inner rectangular boundaries. This paper presents an efficient algorithm which finds k "non-crossing" rectilinear paths in the plane region A, each connecting a terminal pair without passing through any obstacles, whose total length is minimum. Non-crosslng paths may share common points or llne segments but do not cross each other in the plane. The algorithm runs in time O(nlogn) where n = r + k.

1. Introduction This paper deals with a rather unknown topic "non-crossing paths." Non-crossing paths should not cross each other in the plane but may share common points or line segments unlike "disjoint paths." The "non-crossing path problem" asks to find non-crossing paths of minimum total length, each connecting a specified terminal pair in two-dimensional plane regions or plane graphs. Our motivation comes from an application of the problem to VLSI layout design [1,2,3]. For the sake of simplicity, we assume that a VLSI routing region and internal blocks (obstacles) are all rectangular in shape. Usually such a routing region in a VLSI single-layer routing problem is represented by a two-dimensional plane region or a plane graph [3]. We wish to find "shortest" non-crosslng paths (wires) in the region, each of which connects a terminal pair and does not pass through any blocks, and whose total length is minimum. Such shortest non-crosslng paths give a routing which minimizes the area used by wires or the time-delay in VLSI circuits. (See Figure 1.) Let k be the number of terminal pairs, let r be the number of rectangular obstacles, and let n = k + r . D . T . Lee et al. presented an algorithm which finds shortest k non-crossing rectilinear paths in a p l a n e region in time O((k2!)nlogn) [2]. On the other hand, we gave an algorithm which finds shortest k non-crossing paths in a p l a n e g r a p h in time O(nlogn) for the case when all 2k terminals lie on two specified face boundaries [1], where n is the number of vertices in the plane graph. In this paper we consider a plane region A which is bounded by an outer rectangle and an inner one and has r rectangular obstacles inside the region, as depicted in Figure 1. We wish to find shortest non-crossing rectilinear paths passing through none of the obstacles in the plane region A. We give an algorithm

99

s5

8 1( .........

:1

86

87

I ~. :...-:...-

t2 S2

83

t3 t4

S4 Fig. 1. Shortest non-crossing paths in plane region A. which finds such shortest non-crossing paths in A in time O(n logn) for the case when all the terminals are located on the outer and inner boundaries, where n = r + k and neither r nor k is assumed to be a constant. Our idea is to reduce the problem on a plane region to a problem on a plane graph. However a straightforward reduction requires time O(n~logn) as follows. Construct from a given plane region A a plane graph G as depicted in Figure 2(a): add to G all corners of rectangles and all terminals as vertices, draw horizontal and vertical line segments from all these vertices until they hit a rectangle, and then axtd as vertices of G all the intersections of these line segments. One can observe that shortest non-crossing paths in the resulting plane g r a p h G are shortest non-crossing r e c t i l i n e a r paths in the p l a n e region A. Thus one can find shortest non-crossing rectilinear paths in A by applying the algorithm in [1] to G. Such a straightforward algorithm requires time O(n21ogn) since G has O(n2) vertices. Our algorithm in this paper improves the time complexity to O(nlogn). The idea is to divide the plane region A into several subregions, in each of which shortest non-crossing paths may be assumed to run either horizontally or vertically, and is to construct a new plane graph G', as depicted in Figure 2(b), by drawing either horizontal or vertical line segments in each of the subregions. One can show that G' has O(n) vertices and that shortest non-crosslng paths in G' are shortest non-crossing rectilinear paths in A. Thus our algorithm runs in time O(n log n).

2. P r e l i m i n a r i e s In this section we give a formal description of the non-crossing path problem and define several terms. In this paper M 1 rectangles are assumed axls-parallel, that is, all sides axe parallel to x-axis or y-axls. We assume that there is an outmost rectangle Ro and that all rectangular obstacles are contained in Ro and do not overlap each other. Let A be a plane region which is inside Ro and outside the other rectangles, where A contains the boundaries of all rectangles. Let RI be one of the rectangular obstacles in Ro. We call the boundary of Ro the outer

I00 ........

...." ..........

r -'TLT.=7- ........

i

! J I

i

........ .-~.... -.-~.v~ r -7-7--- ........ ..............

.-~.-~.-~ ..~:~ Vo s

.:.' ":'

O

.............. .'

' :".:;':? "."~.

.... o ......

!

s2

sl . . . . . . . . . . . . . . .

s2

"

I:

I

I;~

.......~

~

$]] !.............

3

(a)

Fig. 2. Plane graphs G and G ~ constructed from plane region A.

~oundary Bo of A, mad call the boundary of R1 the inner boundary Bt of A. Let r be the number of rectangles except Ro and RI. A pair of points si and ~i which we wish to connect by a path is caJled a terminalpair (si,ti). Assume that all the terminals are located on the two boundaries Bo and Bs. Let k be the number of terminal pairs. In this paper neither r nor k is assumed to be a constant. We define non-crossing paths in the plane region A as follows. Let P1,-P2,'", P~ be paths in A connecting the k terminal p~irs. Add a new point vo outside Ro, and connect vo to each terminal on Bo with a path. Similarlyi add a new point Vl in RI, and connect vt to each terminal on BI with a path. Let P[, 1 < i < k, be a path (or a cycle) obtained from Pi by adding two new paths: one connecting s; to vo or vz, and the other connecting ti to vo or vI. We define paths P1,P2,'",P~ in region A to be non-crossing (for the boundaries Bo and BI) if P[, 1 < i < k, do not cross each other in the plane. This definition is appropriate for the VLSI single layer routing problem mentioned in Section 1. In Figure 3(a), paths P1 and P2 cross each other (for the boundaries Bo and BI). On the other hand, the three paths P1, P2 and P3 in Figure 3(b), do not cross each other. In this paper we consider only rectilinear paths, that is, those consisting of axls-parallel llne segments. The length of a rectilinear path is the sum of lengths of line segments in the path. Non-crossing paths P1,P2,'",P~ are shortest if the sum of lengths of P1,P2,'",Pk is minimum. Figure 1 depicts shortest non-crossing rectilinear paths in A. It is easy to check the existence of non-crossing paths in A. Therefore we assume that A necessarily contains non-crossing paths, and presents an efficient algorithm which finds the shortest non-crosslng rectilinear paths in A. We then define "monotone" paths. Let z(p) be the z-coordinate of a point p, and let y(p) be the y-coordinate of p. We recursively define an zy-path P starting at a point p, as follows [4]: (a) P is the horizontal line y = y(p) for z > z(p) (not crossing any obstacle); or (b) P follows + z direction to the boundary of a rectangular obstacle, then follows +y direction up to the upper left corner p~ of the rectangular obstacle, and

101

s5

I!!

i

S

1( - -

4

S6

u

i

i

$2(

S?

s5

s6

T btl

S 1'

) t2

= S21

t7 't 6 )t3

S31

S7

S34

tsIt[7tl~~~

~t2

~t 3

)t4 S4I

!

84 ~

(a) G

(b) G"

Fig. 3. Crossing and non-crosslng paths.

then follows an xy-path starting at p'. We si~larly define x ( - y ) , - x y , - x ( - y ) , yx, y ( - x ) , - y x and - y ( - x ) - p a t h s . Define eight paths H1,YI2,...,l'Is starting at the four corners of-RI in A as follows: the yx-path rI1 and the xy-path II2 starting at the upper-right corner, the x(-y)-path II3 and the - y x - p a t h H4 starting at the lower-right corner, the - y ( - x ) - p a t h YIs and the - x ( - y ) - p a t h I-Is starting at the lower-left corner, and the - x y - p a t h H7 and y ( - x ) - p a t h 1-In starting at the upper-left corner. The eight paths are drawn in thick lines in Figure 4(a). Let Hi start at corner q~ and end at point Pl on Bo, then clearly each Hi, 1 < i < 8, is a shortest path in A connecting Pi and q~. We divide A into eight subregions A1, A2,..., As by the eight monotone paths l'I~, 1 < i < 8. Let A~ be the subregion of A inside a cycle consisting of four paths: H;, the path going clockwise from p; to pi+l on Bo, II~+z, and the path going clockwise from ql to qi+z on BI, where i + 1 = 1 if i = 8. Note that A~ includes the boundary of the cycle. The regions A1, A 2 , ' " , As are shaded in Figure 4(a)..

3. S h o r t e s t

non-crossing

paths in the plane region

In this section we present an algorithm for finding shortest non-crossing rectilinear paths P 1 , P 2 , ' " , P k in the plane region A, where each Pi, 1 < i < k, represents a path connecting a terminal pair (sl, tl). We write p E Bo when point p lies on Bo. Similarly, we write p E BI when p lies on BI. One may assume without loss of generality that si E Bo and ti E B1 if either sl or tl is on Bo and the other is on BI. Then the set S of k terminal pairs can be partitioned into the following three subsets:

102

S2S l P8

A s

S5 S6 S7 P~

tl

A

A

1 P2 t2

A2

A

t3

t4 O 3

A 5

P5

A 4

~

A 3

(a) s5

S6

s7

12

t3

l6

t

t4 S4

(b) AIO,qo

(c) A o Pig. 4. Elustration of subregions mad plaale graphs for Case 1.

Sro = {(sl, q)lsi E Bo and fi E BI}, s~ = { ( s . t,)ls, l~ ~ Bx}, ~ d However one m a y assume, without loss of generality, SI = r Otherwise, one caal decide all paths Pi for pMrs (si,r E SI as follows. Let Qi be a path which goes from sl to tl clockwise on Bz, and let Q~ be a path which goes from sl to tl counterclockwise on Bt. Since we assume t h a t there exist non-crossing p a t h s in A, e i t h e r Qi or Q~ passes through none of the terminals of SIO. If $io = r then let Pi be the shorter one of Qi and Q~. If SIo # r let Pi be either Qi or Q~ t h a t passes through none of t h e terminals in SIo. All the paths Pi for $I decided in this way do not cross each other and do not cross any paths for $Io or So, since all these paths Pi traverse only the inner b o u n d a r y B I . T h e set So is p a r t i t i o n e d further into two subsets Sod and Sop:

Sod = {(s;,ti) e So [ si and tl are on the same side or on the two aAjacent sides of R o ),

Sop = {(si,t;) E So [ si and q are on the two parallel sides of Ro }.

103 All the terminals of Sop lie either on the two vertical sides or on the two horizontal sides of Ro; otherwise, there would be no non-crosslng paths. For each pair ($1,~i) E SO, all the terminals sj of SIo fie on one of the two paths in Bo going from si to ti clockwise or counterclockwise. One may further assume that, for each pair (sl, ti) E Son, all the terminals sj of $1o lie on the shorter one of the two paths in Bo: if there is a pair (si, ti) 6 Soa for which all the terminals sj of SIo lie on the longer one of the two paths in Bo, then one can decide Pi to be the shorter one in Bo because Pi is truly shortest in A and does not cross any other paths for So or Sxo. We next divide region A into two subregions Aio and Ao. Let AIo be the union of BI and all of the subregions A1,A2,...,As that contain at least one terminal sj in Sto. Let Ao be the union of all other subregions, then Ao consists of either one or two connected regions. Figure 4 illustrates an example, for which the terminals ss,ss and s7 in Slo lie in As, and hence Aio is the union of BI and As, and Ao is the union of A1, A2, A3, A4, As, As and A7. Clearly Axo contains all the terminals in $Io, but Ao does not always contain all the terminals in So. We shall consider the following two cases. Case 1: AlO does not contain any terminal in So, and Case 2: Otherwise. Consider first Case 1. From AIo and Ao we construct two plane graphs GIo and Go, in which paths are found for Sxo and So, respectively. Gzo is constructed from the outer boundary of A~o and all.the rectangles in Azo, as follows. For each Ai which is contained in Axo and contains a side of _R.r, draw new lines, perpendicular to the side, from all the corners of rectangles and the terminals in Ai until they hit a rectangle or the boundary of Ai. The resulting plane graph is GIo. (See Figure 4(b).) Since either horizontal or vertical lines are drawn in each Ai, Glo has O(n) vertices. On the other hand, Go is constructed from the outer boundary of Ao and the rectangles in Ao, as follows. Consider first the case in which So~ = r that is, all the pairs of terminals in So lie on the two parallel sides of Ro. Then we draw new lines, perpendicular to the sides on which the terminals of So lie, from all terminals and all corners of rectangles in Ao until they hit a rectangle or the boundary of Ao. The resulting graph is Go. Consider next the case in which So~ r r There is a pair in Son, say (sl,ta), such that all the terminals of So lie on the longer one Qx of two paths on Bo going from sl to Ix clockwise or counterclockwise, as shown in Figure 4(a). One may assume that Q1 goes from sx to q counterclockwise on Bo. Let So contain l pairs, then one may further assume that the 21 terminals Sl, s2,..., st-a, s t , h , h - 1 , ' " , t2, r in So appeaz on Q1 in this order. Let m = ISo l, then clearly = {(s,,,,)ll

< i