On Optimal Cuts of Hyperrectangles 1 Introduction - CiteSeerX

1 downloads 0 Views 218KB Size Report
Thereby we assume that a rectangle which is intersected by the cutting plane ... cut. Here, our algorithm uses O(d n logn) time and O(d n) space; this should be ...
On Optimal Cuts of Hyperrectangles Fabrizio d'Amore{

Viet Hai Nguyen

Thomas Roos Peter Widmayer

Abstract We are given a set of n d-dimensional (possibly intersecting) isothetic hyperrectangles. The topic of this paper is the separation of these rectangles by means of a cutting isothetic hyperplane. Thereby we assume that a rectangle which is intersected by the cutting plane is cut into two non-overlapping hyperrectangles. We investigate the behavior of several kinds of balancing functions, as well as their linear combination and present optimal and practical algorithms for computing the corresponding balanced cuts. In addition, we give tight worst-case bounds for the quality of the balanced cuts. Our results include a generalization [1] and a simpli cation [3, 10] of recent results.

Keywords: rectangles, balanced cuts, separation, binary space partition

1 Introduction Given a set of n d-dimensional (possibly intersecting) isothetic hyperrectangles, we consider the problem of separating these rectangles by means of a cutting isothetic hyperplane. If the cutting plane crosses a rectangle, this is cut into two (non-overlapping) hyperrectangles. We present optimal algorithms for computing several kinds of \optimal cuts". Thereby, the objective function can be de ned in di erent ways, leading also to di erent optimal partitions. We consider two important objectives and their linear combination. First, the balance of a partition is de ned to be the di erence of the number of hyperrectangles on either side of the cutting hyperplane after the split. We call a cut that minimizes this number a best balanced cut . Our algorithm for computing a best balanced cut uses O(d n) time and space. The second cutting objective  The authors acknowledge the support of the Swiss National Science Foundation SNF. { Dipartimento di Informatica e Sistemistica, Universita di Roma \La Sapienza", via Salaria 113, I-00198 Roma,

Italia; email: [email protected]  Dept. Informatik, ETH Zentrum, CH{8092 Zurich, Switzerland; email: fnguyen, roos, [email protected]

is to minimize the size of partitions, i.e. the total number of rectangles in the two subspaces. This leads to a so-called minimum intersection cut . However, this second objective function is only useful in conjunction with some criterion that guarantees the balance of the partition. Therefore, we investigate minimum weighted sum partitions with respect to objective functions which can be described as linear combinations of the best balance and minimum intersection cut. Here, our algorithm uses O(d n log n) time and O(d n) space; this should be contrasted with the lower time bound of (n log n). Our results include a generalization of recent results [1, 3, 10]. A solution to these cutting problems has a number of applications; let us name just two. First, a binary space partition (BSP) is a partition that results from a hyperplane cut as described, applied recursively until each region contains no more than a xed number of objects. The number of these regions, the so-called size of the partition, together with the time required to compute a partition of small size, have been studied extensively, and ecient algorithms that nd linear size partitions for line segments in the plane and for pairwise non-overlapping rectangles have been proposed [2, 11, 12]. The trees representing the recursive space decomposition, however, can be unbalanced to such a degree that the tree height is linear in the number of line segments. Nevertheless, for data structures that are based on a partition tree (see, e.g., [5, 9, 13]), a balanced partition with logarithmic tree height is desirable. In addition, rectangles in spatial data structures regularly do overlap, although to a limited extent. The results we present in this paper imply a solution to the balancing problem of BSPs for this situation: we propose a linear time algorithm to compute a balanced partition, and we show that this partition has logarithmic height for limited overlap. On the other hand, for an adequate linear combination of the two objective functions, we show how to create a BSP of small size. 2

Second, the eciency of geometric divide-and-conquer algorithms crucially depends on a basic condition: the size of any of a xed number of subproblems is at most a constant fraction of the size of the original problem. In addition, the subproblems must be of the same kind as the original one, and they should ideally be concerned with two disjoint regions of space. The results in this paper hence lead to a quite general scheme for designing ecient geometric divide-and-conquer algorithms. In [1], it was shown that there always exists a cutting hyperplane separating a set of n

d-dimensional non-overlapping isothetic hyperrectangles into two sets each containing at most

d

d?1 ne hyperrectangles. 2d

2

In addition, an O(d n) time algorithm was presented for computing a

cut satisfying a certain balance condition. This cut, however, is usually far from being a best balanced cut for the particular problem instance at hand. Later, this result was improved and extended to the more general case of so-called k-overlapping rectangles [3], thereby computing a best balanced cut for each problem instance in optimal O(d n) time. Notice that in general no nontrivial upper bound on the size of a set induced by a partitioning hyperplane can be established: for any isothetic hyperplane, parts of all rectangles may be found on one of the two sides. Nevertheless, for the practically important case of limited overlap, like, e.g., in cartography, we derive a tight bound. Actually, it was shown [3] that there always exists a cutting plane which creates two halfspaces with at most d (2d?21)d n+k e rectangles on each side, under the assumption of k-overlapping, where at most k of the rectangles in S are allowed to intersect at a common point. This can be proven by induction on the dimension, which is interesting in its own right. Here, a problem is that the upper bound approaches n in the limit as d increases, thus becoming an overestimated upper bound on the balance in general (not in the worst-case). 3

Using a di erent and more sensitive measure, namely the so-called pro le k of the scene which is de ned to be the maximum number of rectangles (minimized over all dimensions) that touch or intersect an isothetic hyperplane, we obtain tighter bounds for the separation function above. Using this new measure, we can prove the existence of a cutting plane which creates two halfspaces with at most b n+2k c rectangles on each side. The algorithms presented in this paper nd cutting hyperplanes that are best possible for any problem instance, (in most cases) at no extra time or space, asymptotically. Furthermore, our algorithms deal with hyperrectangles that overlap arbitrarily, also at no extra time or space, asymptotically. Since our algorithms are based on one-dimensional projections of higher dimensional rectangles, they also work for arbitrary geometric objects for which a smallest enclosing hyperrectangle (bounding box) can be computed eciently; the cost of this computation, of course, has to be added to the runtime requirements of our partitioning algorithm. The paper is organized as follows. After introducing notations and de nitions in Section 2, Section 3 motivates and presents an ecient and practical algorithm for solving the best balanced cut problem in optimal O(d n) time and space. Section 4 includes a detailed investigation of the best balanced cut problem, proving that there exist tight worst-case bounds for the number of hyperrectangles lying in the two halfspaces de ned by the cut. We give these bounds for both measures, the overlapping factor and the pro le of the scene. In fact, this investigation shows that the pro le is a more sensitive guarantee for the quality of a best balanced cut. Section 5 introduces the second objective function by considering linear combinations of two objective functions that maximize the balance of a partition and minimize the number of intersected rectangles, and it presents an O(d n log n) algorithm for computing such an optimum cut. Finally, Section 6 brie y discusses our results and outlines some applications. 4

2 Preliminaries At the beginning, we are given a set S := fR1; : : :; Rng of n (possibly overlapping) isothetic hyperrectangles1

Ri := [a1i; b1i]  : : :  [adi ; bdi] in d-dimensional real space IRd , i = 1; : : :; n. Any isothetic hyperplane C (which can be regarded as some degenerate isothetic rectangle) separates IRd into two closed half-spaces. Any rectangle

R whose interior is intersected by C is split into two non-overlapping parts corresponding to the respective sides of C . More precisely, for any c 2 ]aj ; bj [, the hyperplane xj = c splits the rectangle R = [a1; b1]  : : :  [ad; bd] into two parts:

Rlow := [a1; b1]  : : :  [aj ; c]  : : :  [ad ; bd] and

Rhigh := [a1; b1]  : : :  [c; bj ]  : : :  [ad ; bd] So, any isothetic hyperplane C induces a partition of S in the sense that some rectangles lie entirely on some side of the hyperplane while others are intersected. Let C < and C > denote the sets of rectangles lying entirely in one of the two halfspaces generated by the cut C , respectively, and let C = denote the set of rectangles whose relative interior is intersected by C . Now, it is desirable to obtain a cutting plane such that (i) the number of rectangles after the split is as small as possible, or equivalently, the number of intersected rectangles is minimized and (ii) the di erence of the numbers of rectangles on both sides of the cutting plane is minimized. For the sake of simplicity, we often refer to hyperrectangles (hyperplanes) simply as rectangles (planes respectively), implicitly assuming that we always talk about scenes in d-dimensional space, except when it is explicitly stated otherwise. 1

5

Formally, we de ne the minimum intersection cut as a cut minimizing the following sum: C = jC < j + jC > j + 2  jC = j where jC j denotes the cardinality of the set C . Note that, since for an arbitrary cut C we have

jC j + jC j = n, minimizing C is equivalent to minimizing the number of intersected =

rectangles jC = j. However, this minimum intersection cut will also lead to degenerate cuts since C  0 outside the scene. Thus, this balance function is only useful when applied in conjunction with some other criterion that guarantees a certain balance of the partition. In opposite to that, a best balanced cut is de ned to be a cut which minimizes the di erence between C < and C > , i.e. C =k jC < j ? jC > j k Thereby, kxk denotes the absolute value of x. In general, these two functions together cannot always be minimized simultaneously. So, we propose a combination, that is to look for a minimum weighted sum cut C which minimizes

C +   C for real positive parameters and  (see Section 5). In the following, we consider all coordinate directions separately. Let Cj be an arbitrary isothetic plane normal to the j -th coordinate direction. Furthermore, let belowj (Cj ) := jCj< j and abovej (Cj ) := jCj> j denote the cardinalities of the sets Cj< and Cj> . In addition, let kj be the maximum number of rectangles that touch or intersect any such cut Cj . With that, the pro le k is de ned to be the minimum of all kj , i.e.

k = minfk1; : : :kdg 6

Let k be the maximum number of rectangles that intersect in a common point; we call the set of rectangles k-overlapping . Notice that unlike [1, 3] we do not assume the rectangles to be in general position.

3 The Best Balanced Cut A rst approach for computing a best balanced partition (in the sense above) would probably sweep the scene of rectangles in each coordinate direction, thereby deriving the optimal solution in O(d n log n) time. Thereby, the set of j -coordinates

Sj := fa1j ; b1j; : : :; anj ; bnj g of the endpoints of the rectangles serve as halting events for the sweeping hyperplane during the sweep process. This space-sweep algorithm, however, is not optimal. This can be seen by investigating the projections of the set S onto the j -th coordinate axis. Let us assume for the moment that the rectangles are in general position , i.e. all endpoints of the multiset Sj are disjoint. In this case, we select a cut Cmj at the \median" mj of Sj between the n-th and the (n + 1)-th point. Thus, no endpoint of Sj coincides with mj . As the number of intersected rectangles Cm=j does not a ect the balance, we can eliminate them, simply because each of the rectangles in Cm=j contributes one entry in Sj to each side of the median mj . Thus, there is still the same number of endpoints of rectangles on both sides of the median mj , and the corresponding rectangles do not overlap the cut Cmj . This proves that the number of rectangles in Cmj is the same, i.e. we obtain a best balanced cut with Cmj = 0. In the case of non-general position , the things turn out to be somewhat more technical. Now, we let mj denote a point in the closed interval de ned by the n-th and the (n +1)-th point of Sj . If mj does not coincide with any endpoint of Sj , the same argument as in the general position 7

k1

.. .. .. .. .. .. .. .. .. .. .. .. .. .. H.....H .. .. .. .. .. mj

k2

Figure 1: Finding a best balanced cut. provides a best balanced cut with Cmj = 0. The diculty, however, arises when the n-th and the (n + 1)-th point of Sj de ne the same point mj , or in other words when there are coincident endpoints of Sj at mj . In this case, we can imagine the k1 and k2 (projection) intervals whose right and left endpoints coincide with mj , respectively, ordered by their length (see Figure 1) within the ordered set of all interval endpoints. Now, we locate the median mj in this ordered set by drawing an arti cial cut which separates the n-th and (n + 1)-th point at mj . This arti cial cut has balance 0. Now, if the arti cial cut would separate the k1 segments which reach to the left from the k2 segments to the right, we would obtain balance 0 for the cut mj . However, the arti cial cut may separate some coinciding segments to the left or the right. W.l.o.g., assume that the separation is to the left (as depicted in Figure 1). In this case, those of the k1 coinciding segments which are intersected by the arti cial cut lie in C < , but according to the median, they should not. That is, their number determines the balance: The function

jCmj j 8

has a value which is the (positive) number of these intersected line segments. Now, if we look at the cut Cmj ?" , for an arbitrary small " > 0, the balance changes by k1 and we obtain the (negative) function value

jCmj, the best balanced cut must be one of the cuts Cmj or Cmj ?" . The other case where the arti cial cut intersects to the right, we obtain a negative value jCmj j and a best balanced cut can be found (analogously) at Cmj or Cmj +" . This provides a balanced cut in the j -th coordinate direction. In fact, we apply this technique to any dimension independently and select the best balanced cut among them.

Theorem 1 Given a set of n possibly overlapping isothetic rectangles in d-dimensional real space, a best balanced cut can be found in optimal O(d n) time and space. There is always a cut C with C  bk=2c, where k denotes the maximum number of coinciding endpoints in any dimension.

Proof: To prove the second part of the theorem which provides an upper bound on the quality of the best balanced cut, recall the construction of the best balanced cut. If Cmj > 0, there must be an intersection with the k1 incident segments to the left or the k2 incident segments to the right. Let us assume again that the intersection is to the left (see Figure 1). Then, however, the number of intersected segments or the number of non-intersected segments of the k1 incident segments is at most k1=2  k=2. But, actually these two numbers describe the balances of the cuts Cm 1 ? 1=n, since then, a minimum weighted sum becomes a minimum intersection cut. These observations lead to the following theorem: 18

u

u

u

u

u

u

x2

x6

x1

x4

x3

x5

s11

s12

s31

s32

s41

s42

s22

s51 s61

s62

Figure 3: Illustrating the transformation to "-closeness.

Theorem 5 Given a set of n possibly overlapping isothetic rectangles in d-dimensional real space, a minimum weighted sum cut for C = C +  C , where   , can be found in O(d n) time and space. In the case of >  , the function C can be minimized in O(d n log n) time and O(d n) space. For constant d, this is optimal.

6 Conclusion and Generalizations We have presented an approach for computing minimal cuts under measures such as the balance and the size of the partition. In addition, we gave tight worst-case bounds on the size of the partition which prove that there exist binary space partitions of logarithmic height. Notice that the recursive application of the best balanced cut implies an upper bound of at most O(nlog 2 ) for the total size of the BSP, where  = 2d2?d 1 . In fact, we always obtain a BSP with total size at most O(nd ): If we look at the BSP generated by a sequence of best balanced cuts, there is only a linear number of cuts for each coordinate direction. Thus, the d-dimensional arrangement formed by the cutting planes has complexity O(nd ) and each cell of this arrangement has constant complexity. This is also a tight bound because there exist worst-case examples which generate BSPs of size (nd ) even if we relax the balancing condition. 19

Our approach can be generalized to more general classes of objects, e.g. convex objects. In this case, our algorithm and all investigations of the best achievable balance apply to the bounding boxes of the objects, as well. All we have to demand to preserve our runtime and space

bounds is that the boundaries of the bounding boxes of the objects can be computed in O(d) time, each. In contrast, if we drop the restriction that the cutting hyperplanes be isothetic, there is a very recent result [6] showing that there exist BSPs of linear size in the plane under special assumptions.

Acknowledgement ...

References [1] F. d'Amore and P.G. Franciosa, Separating Sets of Hyperrectangles, Intern. J. of Comp. Geometry & Appl., Vol. 3, No. 2, 155 { 165 (1993) [2] F. d'Amore and P.G. Franciosa, On the Optimal Binary Plane Partition for Sets of Isothetic Rectangles , Proc. 4th Canadian Conf. on Comp. Geometry, St. John's, Newfoundland, 1 { 5

(1992) [3] F. d'Amore, T. Roos and P. Widmayer, An optimal algorithm for computing a best cut of a set of hyperrectangles , in Graphics, Design and Visualization (IFIP Transactions B-9), S.P.

Mudur, S.N. Pattanaik (Eds), Elsevier Science B.V. (1993) [4] M. Ben-Or, Lower Bounds for Algebraic Computation Trees , Proc. 15th ACM STOC, 80 { 86 (1983)

20

[5] J.L. Bentley, Multidimensional Binary Search Trees used for Associative Searching , Comm. ACM, Vol. 18, No. 9, 509 { 517 (1975) [6] M. de Berg, M. de Groot and M. Overmars, New Results on Binary Space Partitions in the Plane , Proc. SWAT'94, LNCS 824, 61 { 72 (1994)

[7] M.L. Fredman and B. Weide, On the complexity of computing the measure of [[ai ; bi], Comm. ACM, Vol. 21, No. 7, 540 { 544 (1978) [8] A. Guttman, R-trees: A Dynamic Index Structure for Spatial Searching , Proc. ACM SIGMOD, 47 { 57 (1984) [9] J. Nievergelt, H. Hinterberger and K.C. Sevcik, The Grid File: An Adaptable, Symmetric Multikey File Structure , ACM Trans. on Database Systems, Vol. 9, No. 1, 38 { 71 (1984)

[10] V.H. Nguyen, T. Roos and P. Widmayer, Balanced Cuts of a set of hyperrectangles, Proc. 5th Canadian Conf. on Comp. Geometry, Waterloo, Ontario, 121 { 126 (1993) [11] M.S. Paterson and F.F. Yao, Binary Space Partitions with Applications to Hidden Surface Removal and Solid Modelling , Proc. 5th Annual ACM Symp. on Comp. Geometry,

Saarbrucken, 23 { 32 (1989) [12] M.S. Paterson and F.F. Yao, Optimal Binary Space Partitions for Orthogonal Objects , Proc. 1st ACM-SIAM Symp. on Discrete Algorithms, San Francisco, 100 { 106 (1990) [13] H. Samet, The Design and Analysis of Spatial Data Structures , Addison-Wesley, 1990

21