Faster Algorithms for Growing Prioritized Disks and Rectangles
Hee-Kap Ahn, Sang Won Bae, Jongmin Choi, Matias Korman, Wolfgang, Mulzer, Eunjin Oh, Ji-won Park, Andr\'e van Renssen, Antoine Vigneron

TL;DR
This paper introduces the first subquadratic algorithm for the growing prioritized disks problem, extending to other shapes and dimensions, with improved running times and near-tight bounds, motivated by map labeling applications.
Contribution
It presents the first general subquadratic algorithm for growing prioritized disks, extends the approach to other shapes and dimensions, and provides a quadtree-based algorithm with improved efficiency.
Findings
First subquadratic algorithm for the problem
Extension to rectangles and higher dimensions
Quadtree algorithm with near-optimal bounds
Abstract
Motivated by map labeling, Funke, Krumpe, and Storandt [IWOCA 2016] introduced the following problem: we are given a sequence of disks in the plane. Initially, all disks have radius , and they grow at constant, but possibly different, speeds. Whenever two disks touch, the one with the higher index disappears. The goal is to determine the elimination order, i.e., the order in which the disks disappear. We provide the first general subquadratic algorithm for this problem. Our solution extends to other shapes (e.g., rectangles), and it works in any fixed dimension. We also describe an alternative algorithm that is based on quadtrees. Its running time is , where is the ratio of the fastest and the slowest growth rate and is the ratio of the largest and the smallest distance between two disk centers.…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Faster Algorithms for Growing Prioritized Disks and
Rectangles111A preliminary version appeared as H.-K.-Ahn, S. W. Bae, J. Choi, M. Korman, W. Mulzer, E. Oh, J.-W. Park, A. v. Renssen, A. Vigneron. Faster Algorithms for Growing Prioritized Disks and Rectangles. Proc. 28th ISAAC, pp. 3:1–3:13. The work by H.-K. Ahn, J. Choi, E. Oh was supported by the MSIT (Ministry of Science and ICT), Korea, under the SW Starlab support program (IITP–2017–0–00905) supervised by the IITP (Institute for Information & communications Technology Promotion.). S.W. Bae was supported by Basic Science Research Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Education (2015R1D1A1A01057220 and 2018R1D1A1B07042755). M. Korman was supported in part by NSF awards CCF-1422311 and KAKENHI No. 17K12635, Japan. W. Mulzer was supported in part by DFG Grants MU 3501/1 and MU 3501/2 and by ERC StG 757609. J.-W. Park was supported by the NRF Grant 2011-0030044 (SRC-GAIA) funded by the Korea government (MSIP). A. v. Renssen was supported by JST ERATO Grant Number JPMJER1201, Japan. A. Vigneron was supported by the 2016 Research Fund (1.160054.01) of UNIST (Ulsan National Institute of Science and Technology).
Hee-Kap Ahn
Department of Computer Science and Engineering, POSTECH, Republic of Korea
{heekap, icothos, jin9082}@postech.ac.kr
Sang Won Bae
Division of Computer Science and Engineering, Kyonggi University, Republic of Korea
Jongmin Choi
Department of Computer Science and Engineering, POSTECH, Republic of Korea
{heekap, icothos, jin9082}@postech.ac.kr
Matias Korman
Department of Computer Science, Tufts University, United States
Wolfgang Mulzer
Institut für Informatik, Freie Universität Berlin, Germany
Eunjin Oh
Department of Computer Science and Engineering, POSTECH, Republic of Korea
{heekap, icothos, jin9082}@postech.ac.kr
Ji-won Park
School of Computing, KAIST, Republic of Korea
André van Renssen
School of Computer Science, University of Sydney, Sydney, Australia
Antoine Vigneron
School of Electrical and Computer Engineering, UNIST, Republic of Korea
Abstract
Motivated by map labeling, Funke, Krumpe, and Storandt [IWOCA 2016] introduced the following problem: we are given a sequence of disks in the plane. Initially, all disks have radius [math], and they grow at constant, but possibly different, speeds. Whenever two disks touch, the one with the higher index disappears. The goal is to determine the elimination order, i.e., the order in which the disks disappear. We provide the first general subquadratic algorithm for this problem. Our solution extends to other shapes (e.g., rectangles), and it works in any fixed dimension.
We also describe an alternative algorithm that is based on quadtrees. Its running time is O\big{(}n\big{(}\log n+\min\{\log\Delta,\log\Phi\}\big{)}\big{)}, where is the ratio of the fastest and the slowest growth rate and is the ratio of the largest and the smallest distance between two disk centers. This improves the running times of previous algorithms by Funke, Krumpe, and Storandt [IWOCA 2016], Bahrdt et al. [ALENEX 2017], and Funke and Storandt [EuroCG 2017].
Finally, we give an lower bound, showing that our quadtree algorithms are almost tight.
1 Introduction
Suppose we have a digital map in which certain locations are marked with textual labels. As we zoom out, the visible area increases, while the individual features become smaller. To keep readability, the labels must grow during the zooming process. At some point, the labels will collide, and some of them have to be eliminated to avoid clutter. For an efficient implementation, we would like to determine when and in which order the labels disappear.
This can be formalized as follows: we are given a sequence of growing disks. Each disk starts out as a point , and it grows with a fixed growth rate . Thus, at any time , the disk is centered at and has radius . The index corresponds to the priority (a smaller index means a higher priority). When two disks meet, we eliminate the one with lower priority from the arrangement. More precisely, for , let be the time when and touch. Then, if neither nor has been removed before time , we eliminate at this time, while remains. Our goal is to determine the elimination order, that is, the instants of time and the order in which the disks are removed. In this version, we chose to represent the labels as disks, but many other shapes are possible, e.g., to model rectangular labels or map icons with more complex boundary shapes. Thus, it is desirable to have a solution that is widely applicable and adapts easily to small variations in the problem statement.
This problem was introduced by Funke, Krumpe, and Storandt [10]. They observed that a straightforward simulation of the growth process with a priority queue runs in time . They also gave an algorithm that takes expected time O\big{(}n(\log^{6}n+\Delta^{2}\log^{2}n+\Delta^{4}\log n)\big{)}, where is the maximum ratio between two growth rates. Subsequently, Bahrdt et al. [2] improved this to an algorithm that runs in worst-case time O\big{(}\Delta^{2}n(\log n+\Delta^{2})\big{)}. This generalizes to growing balls in arbitrary fixed dimension , with running time O\big{(}\Delta^{d}n(\log n+\Delta^{d})\big{)}. Recently, Funke and Storandt [11] presented two further parameterized algorithms for the problem. The first algorithm runs in time O\big{(}n\log\Delta(\log n+\Delta^{d-1})\big{)}, for arbitrary dimension , while the second algorithm is restricted to the plane and runs in time O\big{(}Cn\log^{O(1)}n\big{)}, where denotes the number of distinct growth rates. If we are interested in finding only the first pair of touching disks, our problem becomes the weighted closest pair of the disk centers. Formann showed how to compute it in time, which is optimal [9].
Our results.
We present a simple algorithm that runs in time in any fixed dimension (Section 2). For a faster running time, this method can be combined with bucketing and an advanced query data structure for lower envelopes of algebraic surfaces [1, 15] (Section 3). This yields an algorithm with expected time for disks and expected time for rectangles in two dimensions. These are the first subquadratic-time algorithms for the problem. More generally, we show that the elimination sequence of a set of growing objects of any semi-algebraic shape described with parameters can be computed in subquadratic time, for any fixed . In Section 4, we consider the case of growing squares. These objects are much simpler, and we can use ray shooting techniques to get a near-linear running time of .
We also consider a completely different approach based on quadtrees (Section 5). The running time of these algorithms also depends on the spread of the disk centers (the ratio of the maximum and the minimum distance between two disk centers) and the ratio between the fastest and slowest growth rate. Table 1 summarizes our results. Finally, we give an lower bound with a simple reduction from sorting. Our method using compressed quadtrees is thus nearly optimal.
Note.
Parallel to our work, Castermans et al. [5] considered a related problem for growing squares in the plane. Whenever two squares meet, they are replaced by a new one located at their weighted center. They are also interested in the elimination/replacement sequence. Even though our algorithms are slightly faster (by polylogarithmic factors) and more general (their algorithm can only handle squares), they are not comparable, since our techniques do not apply in the setting where replacements are possible.
Notation.
For any , we denote by the time when disk is eliminated. Since remains throughout, we set . We denote by the time at which the disks and would touch, supposing that no other disk has interfered. We assume general position in the sense that all times , for , are pairwise distinct.
2 A simple quadratic algorithm
We present a simple iterative way to determine the elimination times . This method will be useful in our bucketing scheme. As noted above, we have . We need a way to determine if are known, for . The next lemma shows how to do this: we just need to find the disk of higher priority that first touches and is still alive at that point.
Lemma 2.1**.**
Let , and let
[TABLE]
Then, the disk is eliminated by the disk , and .
Proof.
On the one hand, we have , because at time , the disk would meet the disk that has higher priority and that has not been eliminated yet (by (1), we have ). On the other hand, we have , because every disk that could meet before time either has lower priority or has been eliminated before the encounter. ∎
The condition (1) can be implemented with a straightforward for-loop. This leads to Algorithm 1.
Theorem 2.2**.**
Algorithm 1 computes the elimination order of a set of prioritized disks in time and space. It generalizes to growing objects of any shape in such that the touching time of any pair of them can be computed in steps, with running time .
Proof.
The correctness follows directly from Lemma 2.1. The running time and space analysis is straightforward. Lemma 2.1 is purely combinatorial and requires only that the times are well defined. Thus, Algorithm 1 can be generalized by using an appropriate -time subroutine for computing . Then, the claim is immediate. ∎
In particular, Theorem 2.2 shows that the elimination order for -dimensional balls or rectangles can be computed in time, for any .
3 A subquadratic algorithm using bucketing
We now improve Algorithm 1 with bucketing and an appropriate data structure. The main idea is as follows: in Algorithm 1, we go through the disks by decreasing order of priority and determine for each one which disk eliminates it. This is done by examining each disk of higher priority individually, leading to a quadratic running time. To avoid this, we partition the disks into buckets of size , where will be fixed later. For each bucket , we build a data structure that can find in sublinear time the disk in that eliminates the current disk. Thus, we process the disks in each bucket with a single query, at the expense of an additional overhead for building the data structure. Furthermore, we must compute the elimination events within each bucket, using Algorithm 1.
Elimination queries.
We now describe the query data structure that is used in a single bucket. Let be a contiguous set of indices, and suppose we know the elimination time of every disks with . In an elimination query, we are given a query index , and we ask for the disk with , that eliminates the query disk (i.e., the first disk in that meets and that has not been eliminated yet by any other disk of higher priority). The argument from Lemma 2.1 shows that we can find by the following slight adaptation of (1):
[TABLE]
This leads to a natural interpretation of elimination queries as vertical ray shooting with four-dimensional lower envelopes: a growing disk corresponds to a point , where is the center of and is the growth rate. For each , consider the function defined by
[TABLE]
where t\big{(}(x,y,v),j\big{)} denotes the time when and the growing disk given by touch. For , let be the point that represents . Then, (2) tells us that the elimination query corresponds to finding the value vertically above and the index of the function that attains it. The pointwise minimum is called the lower envelope of the functions , and the problem of determining the function that achieves this minimum for a given is called a vertical ray shooting query. Vertical ray shooting in lower envelopes is a well-studied problem in computational geometry [12]. In our case, we can apply the following result of Agarwal et al. [1]:
Theorem 3.1** (Theorem 3.3 in Agarwal et al. [1]).**
Let be a given collection of trivariate, possibly partially defined functions, all algebraic of constant maximum degree, and whose domains of definition (if they are partially defined) are each defined by a constant number of algebraic equalities and inequalities of constant maximum degree. Then, for any , the lower envelope of can be computed in randomized expected time , and stored in a data structure of size , so that, given any query point , we can compute , as well as the function(s)* attaining at in time.*
The data structure of Agarwal et al. [1] works by first computing the [math]-, -, and -dimensional faces of the minimization diagram for , i.e., the maximally connected regions in in which the lower envelope of is achieved by four, three, or two functions from . For this, we go over all pairs of distinct functions in , and we determine the part of the two-dimensional surface where the lower envelope is achieved by and . This can be done in expected time with a randomized incremental construction, by inserting the functions from in a random order and keeping track of (the trapezoidal decomposition of) the part of that is not cut off by any function inserted so far [1, Theorem 2.3]. Once the faces of the minimization diagram are available, it can be converted into a suitably well-behaved subdivision of [1, Lemma 3.1] to which the point location structure of Preparata and Tamassia can be applied [18]. The structure of Preparata and Tamassia requires O\big{(}m^{3+\varepsilon}\big{)} space and preprocessing time, while a query needs O\big{(}\log^{2}m\big{)} steps. The result from Theorem 3.1 follows. This directly translates into the following lemma on elimination queries:
Lemma 3.2**.**
Let with . Then, for any fixed , elimination queries for can be answered in time, using space and expected preprocessing time .
Bucketing.
With all the tools in place, we can now describe our subquadratic algorithm. We group the disks into buckets , such that the th bucket contains the disks , , (the last bucket might not be full). There are buckets, each with at most disks. As in Algorithm 1, we compute the elimination times , in this order. As soon as the elimination times of all the disks in a bucket have been determined, we construct the elimination query data structure for . By Lemma 3.2, for each bucket, this takes expected time and space, for a total of expected time and space.
Now, in order to determine the elimination time of a disk , we must check all the previous buckets (as well as the bucket containing ). We first perform elimination queries for all previous buckets, that is, the buckets with . There are such queries, each taking time. Then, we handle the disks that are in the same bucket as by inspecting all of them, which takes time. We return the smallest of all the resulting elimination times. The total time, for , is thus . Overall, we obtain an expected running time of . We balance the terms by setting , to get an algorithm that takes space and expected time.
Theorem 3.3**.**
The elimination sequence of a set of growing disks can be computed in space and expected time, for any fixed .
Generalizations.
The subquadratic algorithm generalizes to other shapes. For example, consider the problem of growing rectangles in . Each rectangle is given by the - and -coordinates of two opposing corners at time (this lets us deduce the center and the speed of the rectangle). These are four parameters, so elimination queries now can be handled by vertical ray shooting in lower envelopes in . In this setting, we employ a general data structure for point location in arrangements of high-dimensional surfaces or surface patches. Chazelle et al. [8] presented such a structure, based on geometric divide and conquer. Their result requires a decomposition of (subsets of) this arrangement into elementary cells of constant complexity and depends on the complexity of such a decomposition. The best relevant bounds are due to Koltun [15]. By plugging his combinatorial bounds into the scheme of Chazelle et al. [8], he obtains the following theorem:
Theorem 3.4** (Theorem 5.1 in [15]).**
A collection of fixed-degree algebraic surfaces or surface patches in , for , can be preprocessed in time into a data structure of size such that the cell in the arrangement of that contains a query point can be located in time .
A few remarks are in order: the bound in Theorem 3.4 holds for any fixed . The preprocessing algorithm is deterministic (for this, we need to replace the random sampling step in the scheme of Chazelle et al. [8] with the deterministic -net construction by Chazelle and Matoušek [6, Theorem 4.6], which can be done in a black box fashion). Since the point location actually takes place in the vertical decomposition of the arrangement of , Theorem 3.4 can also be used for vertical ray shooting. Thus, for our case of growing rectangles, Theorem 3.4 means that a data structure for elimination queries with query time can be constructed in space and time, for any fixed .
We now apply the same approach as for growing disks. With bucket size , we then obtain an algorithm that determines the elimination order in time. Setting to balance the terms, we get the following result:
Theorem 3.5**.**
The elimination sequence of a set of growing rectangles can be computed in O\big{(}n^{11/6+\varepsilon}\big{)} deterministic time and space, for any .
More generally, we can use Theorem 3.4 to handle elimination queries for regions defined by any semi-algebraic shape of constant complexity. If the shape of the object is described with parameters, elimination queries translate to vertical ray shooting in the lower envelope of surfaces or surface patches in . The bucketing approach and Theorem 3.4 then yield an algorithm that needs time and space. We balance the terms with . This gives an overall running time of , which is subquadratic for any fixed .
Theorem 3.6**.**
The elimination sequence of a set of growing objects of any semi-algebraic shape, each described with parameters can be computed in deterministic time and space, for any .
4 Growing cubes
Axis-aligned cubes in are given by parameters. Thus, the general approach from Section 3 applies. However, for axis-aligned cubes, much better data structures for orthogonal range searching and for planar ray-shooting can be leveraged for elimination queries. In this section, we combine bucketing with orthogonal range searching and ray shooting techniques to achieve an almost linear bound.
To simplify the presentation, we first focus on the case . A sequence of growing squares is given by the centers and the growth rates . At time , each square has edge length . We consider the four quadrants around each center . The north, east, south, and west quadrants are, respectively, \big{\{}(x,y)\in\mathbb{R}^{2}\mid y-y_{i}\geq|x-x_{i}|\big{\}}, \big{\{}(x,y)\in\mathbb{R}^{2}\mid x-x_{i}\geq|y-y_{i}|\big{\}}, \big{\{}(x,y)\in\mathbb{R}^{2}\mid-(y-y_{i})\geq|x-x_{i}|\big{\}}, and \big{\{}(x,y)\in\mathbb{R}^{2}\mid-(x-x_{i})\geq|y-y_{i}|\big{\}}, see Figure 1.
The quadrants determine which sides of the growing square are relevant for the elimination time. For example, suppose that the center of the disk is in the north quadrant of . Then, and will meet when the top side of touches the bottom side of , and the possible elimination time of and is . This can be used for more efficient elimination queries as follows: suppose we have a set of growing cubes, and let such that all centers with lie in the north quadrant of . Then, an elimination query for in just depends on the -coordinates of the disk centers and the growth rates, the -coordinates become irrelevant. Thus, we can reduce these elimination queries to two-dimensional ray-shooting.
Lemma 4.1**.**
Let , . We can preprocess in time into a data structure of space, so that elimination queries can be answered with time, given that the centers of the squares in lie in the north quadrant of the query square .
Proof.
We equip the plane with a coordinate system in which the horizontal direction is labeled and the vertical direction is labeled . For each , consider the line segment , defined for ; see Figure 2. Let be the lower envelope of the line segments. An edge of is a maximal contiguous interval where the minimum is achieved by a single function . All the line segments begin on the -axis. This means that for any pair , of line segments, and can alternate at most twice on (i.e., there can be an edge from , later an edge from , and again later an edge from , but after that cannot appear again). Combinatorially, this corresponds to a Davenport-Schinzel sequence of order with alphabet size , i.e., a sequence of symbols from a finite set with elements such that for any two symbols , the pattern does not appear in [19]. It is well known that such a sequence has length at most [16, Chapter 7.1].
An elimination query for a square with center and growth rate translates to shooting a ray from the point with slope . Since and all line segments originate from the -axis, and since starts below the lower envelope , the point where meets the first line segment must lie on . Thus, we first compute in time [14], and then we build a ray-shooting data structure for . The latter can be done with preprocessing time and space, and a query time of [7]. The result follows. ∎
We now show how to handle more general elimination queries where we do not require to be in the north quadrant of . This is done using methods from orthogonal range searching.
Lemma 4.2**.**
Let , . We can preprocess in time into a data structure of space, so that elimination queries can be answered in time.
Proof.
For any square , we must be able to perform elimination queries on for all four quadrants that are defined by the center of .
This is done as follows: let be the centers of the squares in . We build a two-dimensional range tree for [3, Chapter 5.3], where the coordinate axes have been rotated by an angle of . More precisely, let the rotated coordinates be and . We sort according to the coordinate, and we build a perfect binary tree on for this order, such that the leaves of correspond to the points in . The height of is , and each node of corresponds to a subset of , namely the leaves in the subtree under . Each point of appears in subsets. Next, we determine the -order in each subset , and we build a binary tree on each for that order, as before. Again, for every node of , each node of corresponds to a subset of . We call the subsets the canonical sets, see Figure 3(left) for an example. Each point in appears in subsets , so the total size of all canonical sets is . For each canonical set , we build four elimination query structures as in Lemma 4.1, one for each quadrant. The total preprocessing time is , and the total space requirement is .
Now, to process a query , we determine the four quadrants of , and for each quadrant , we find the canonical sets that constitute a partition of . For this, we locate the -coordinate of the vertical boundary of in , and we take all the nodes that are left or right children of the nodes on this search path, depending on whether lies to the left or to the right of in the rotated coordinate system. Then, we perform an analogous query in the second level tree for each such node, using the -coordinate of the horizontal boundary of . This gives canonical sets that constitute a partition of . We do an elimination query for each canonical set, and we return the element that gives the minimum elimination time for . We repeat this for all four quadrants, and we find the element with the minimum overall elimination time. Since we query canonical sets in total, this takes time. ∎
As in Section 3, we now apply Lemma 4.2 together with the bucketing technique. This time, however, the bucketing is done in a slightly different way: we construct a perfect binary tree whose leaves represent the squares , in that order. A node represents the subset of disks that consists of the leaves in the subtree rooted in .
As soon as the elimination times of all the disks associated with a node of have been determined, we compute the elimination query structure from Lemma 4.2 for . Thus, when processing a disk , the disks , , can be partitioned into buckets for which elimination query structures have been constructed (at most one node per level in the tree), see Figure 3(right). Hence, we can find in time by querying all these structures. Since each disk apperas in structures, the total preprocessing time is and the total space requirement is . In higher dimensions, these bounds increase by a factor per dimension, as we need one more level in the range tree. The following theorem summarizes our result.
Theorem 4.3**.**
The elimination sequence of a set of axis-aligned cubes in fixed dimension can be computed in time, using space.
5 Quadtree-based approach
Algorithm 1 can be improved further by noticing that in order to find out when a disk is eliminated, it suffices to check only disks that are nearby. Thus, we need a suitable data structure to maintain the proximity relations between the disks. For this, we use a quadtree. The nodes in the quadtree allow us to approximate the disks by square cells and to efficiently maintain subsets of nearby disks during the growth process. The main drawback is that the complexity of the algorithm will depend on the structure of the point set and not just on the number of points. By compressing the quadtree, we can reduce this dependency, but not completely eliminate it. More precisely, let denote the spread of the disk centers and denote the ratio of the growth rates, i.e.,
[TABLE]
and
[TABLE]
We provide two algorithms: the first algorithm uses a quadtree and runs in time and space. The second algorithm uses a compressed quadtree, and it needs time and space. To simplify the notation, we set .
5.1 A simple quadtree-based algorithm
We give a simple quadtree-based algorithm to compute the elimination sequence for a set of growing disks in the plane. For this, we first construct a modified quadtree for the disk centers: suppose that the maximum distance between two disk centers is and the minimum distance is . Then, will have depth , and each disk center will be in a leaf cell of diameter . The growth process of a disk can be approximated by tracing the quadtree cells from the leaf cell that contains to the root. It turns out that if two disks collide, then their respective cell approximations must be “close” in the quadtree and of approximately the same size (roughly up to a factor of ). This means that for each approximate disk (i.e., quadtree cell), there are other approximate disks that could potentially eliminate it. Thus, we reduce the number of disk pairs that need to be checked in the main loop of Algorithm 1 from to . Details follow.
Without loss of generality, we assume that all disk centers lie in the unit square , and that the diameter of this point set is . We construct a quadtree for the disk centers [17], with a slight modification. The quadtree is a rooted tree in which every internal node has four children. Each node of has an associated square cell . To obtain , we recursively split the unit square. In each step, the current node is partitioned into four congruent quadrants (cells) if its corresponding cell contains one or more disk centers. We stop when each cell at the bottom level contains at most one disk center and the diameter of the cell becomes smaller than a quarter of the smallest distance between two disk centers. Note that in our quadtree, all leaf cells have the same size and are small in relation to the smallest distance between two disk centers; see Figure 4. The quadtree has depth , and it can be constructed in time and space.
We introduce some notation. For a node , we let be the parent node of . We denote by the diameter of the cell . For two nodes , we write for the smallest distance between a point in and a point in . For a point and a node , we write for the smallest distance between and a point in . The next definitions show what it means to approximate a disk by a quadtree cell. For , we let be the disk at time . We say that occupies a node if
- (i)
the disk center lies in the cell for , i.e., ; 2. (ii)
is a leaf or covers the whole cell for , i.e., ; and 3. (iii)
has not been eliminated before time .
We denote by the node of the largest cell of that is occupied by . We may think of as an approximate representation in of disk at time . The next lemma shows that if two disks meet, then their respective approximate representations must be close and of approximately the same size.
Lemma 5.1**.**
Let , and let , be the disk that eliminates , i.e., . Then,
[TABLE]
and
[TABLE]
Proof.
We state three simple facts from the construction of and from the definition of :
- (i)
all non-empty leaf cells have the same diameter (this is how we construct ); 2. (ii)
for any and , if is not a leaf, then ( has radius and covers ); and 3. (iii)
for any and , we have ( has radius and does not cover the parent of , which has diameter ).
For the first claim, on the distance between the cells, let be the point where and touch; see Figure 5. By fact (iii), we have and . Hence, it follows that
[TABLE]
as claimed. Now we prove the second claim, on the ratio of the cell sizes; see Table 2 for an overview of the case distinction. Suppose first that . If is a leaf, we have , by fact (i). If is not a leaf, it follows from facts (ii) and (iii) that
[TABLE]
By construction, the leaf cell that contains has diameter smaller than a quarter of the smallest distance between disk centers. Hence, the node is not a leaf. Thus, by facts (ii) and (iii),
[TABLE]
The argument for is analogous: if is a leaf, then , by fact (i). If not,
[TABLE]
by facts (ii) and (iii). Now, the node cannot be a leaf, so by facts (ii) and (iii)
[TABLE]
The lemma follows. ∎
Lemma 5.1 gives a necessary condition for the event that two quadtree cells could lead to an elimination event. This allows us to focus on a limited number of candidate pairs. More formally, we say that two unrelated222That is, no node is an ancestor or descendant of the other node. nodes form a candidate pair if
[TABLE]
and
[TABLE]
We say that forms the candidate pair with . We denote by the set of candidate pairs formed by . By Lemma 5.1, to determine the elimination order, we need to consider only candidate pairs. The following lemma uses a simple volume argument to bound their number.
Lemma 5.2**.**
Let . Then, contains candidate pairs with . The total number of candidate pairs is .
Proof.
Fix a node . We claim that in each level of , there are at most nodes with such that is a candidate pair. This follows from a simple volume argument: fix a level of , and let be the set of all nodes at level with and . By (*) and our assumption , we have for all that
[TABLE]
Hence, all cells lie in a region of diameter at most . Since these cells have pairwise disjoint interiors and the same size , it follows that , as claimed.
Furthermore, by the definition of and by (), we have . This implies that the levels of and in differ by . Hence, contains candidate pairs with . Since has nodes, and since the symmetry of (*) and () shows that if and only if , it follows that there are candidate pairs overall. ∎
Now we can describe our algorithm. As in Algorithm 1, we handle the disks in decreasing order of priority. Recall that by (1), for each disk , we need to find the disk , , that first meets and is still alive. By Lemma 5.1, it suffices to focus on disks that correspond to candidate pairs. Throughout the algorithm, we compute for each node in the index of the (at most one) disk that occupies it at some point in time. When processing a disk , we start from the leaf node for , and we simulate the growth of by tracing a path to the root. As we follow the leaf-root path for , we check all the candidate pairs for the current node , to see if a node is occupied by a disk that could eliminate (i.e., a disk of higher priority that is still alive when it meets ). These disks have been computed in previous iterations of the algorithm. We continue along the leaf-root path for until it is clear that has been eliminated before it can occupy the current node , setting the variables accordingly. The pseudocode in Algorithm 2 provides the details. Initially, we set all . We use to denote the first time at which is covered by the disk . We will describe below how the sets can be computed efficiently.
Theorem 5.3**.**
The elimination sequence of growing disks can be computed in time and space, where .
Proof.
The outer for-loop iterates over the input disks by decreasing order of priority. In the while-loop, the algorithm traverses each node from the leaf-node with to the root. It updates , until it encounters a node with . The inner for-loop iterates over every candidate pair in . It checks if disk and might touch by computing the time ; if so, it updates the tentative elimination time for . To show correctness, we prove that the algorithm maintains the following invariant: after iterations of the for-loop, the algorithm has correctly computed the elimination times for . Furthermore, for each node of , we have , and if there is a point in time when is occupied by the disk , , then .
The invariant holds after the first iteration. This is because is set to in Line 6, and all ’s are initalized to , so that the while-loop will proceed all the way to the root and set all ’s along the leaf-root path for to . Now suppose that and that is eliminated by the disk , with . By Lemma 5.1, the pair is a candidate pair in . Furthermore, lies on the leaf-root path for and by the inductive hypothesis, we have . Again by the inductive hypothesis and by the test in Line 10, we have throughout the while-loop. Thus, the while-loop will visit and the candidate pair will be considered. At this point, Algorithm 2 will detect the elimination event and set to . After that, the test in Line 7 ensures that the remaining variables are set correctly. In particular, the algorithm does not overwrite any other such values from previous iterations. Thus, the invariant is maintained.
We now turn to the running time. We can compute in Line 2 in time and space. Furthermore, by Lemma 5.2, there are candidate pairs overall, so that the total time for the for-loop, excluding the time for finding the candidate pairs, is . We find the candidate pairs without additional asymptotic overhead as follows: to determine the leaf for , we walk down from the root, going from one node that contains to the next. Suppose that we are currently at level , and that the node contains in . We find all nodes at level with , and we store them in a list for level . For this, we can use appropriate pointers in , or we perform an appropriate root-leaf traversal of that keeps track of all nodes close to the nodes containing . By a simple volume argument, there are such nodes at each level, for a total of . To find for a node , we consider the list for the parent of that is levels above (including the parent), and we perform a depth-first search in of these nodes and their descendants for all candidate pairs. This takes time, and it can be implemented so that the space requirement does not exceed , since we can process the candidate pairs immediately as we discover them. Finally, since , the sorting step in Line 16 does not increase the asymptotic running time or space.333By a packing argument, the spread of any -dimensional -point set is : if any two points have distance at least , the point set must cover at least units of volume and hence must have diameter . ∎
5.2 Using a compressed quadtree
We now speed up Algorithm 2 with the help of a compressed quadtree . In , the number of nodes is reduced to by replacing certain long paths in the uncompressed quadtree with single compressed edges. Now, the definition of the candidate pairs becomes more tricky, because the cells identified in Lemma 5.1 might no longer be present after the compression. Thus, we need a way to map candidate pairs in to candidate pairs in . It is important that no elimination event is missed and that the number of candidate pairs is small. To achieve this we project a candidate pair in to the pair given by the lowest ancestors of and of that appear in . With these compressed candidate pairs, we can essentially run Algorithm 2 on , with minor modifications. To complete our result, we must show that the compressed candidate pairs are few and can be found efficiently, and that no elimination event is missed. Details follow.
We begin with the formal definition of the compressed quadtree. Let be the (uncompressed) quadtree for the disk centers, as in Section 5.1. We describe how to obtain the compressed quadtree from . A node in is empty if does not contain a disk-center, and non-empty otherwise. A singular path in is a path of nodes such that (i) is a non-empty leaf or has at least two non-empty children; and (ii) for , the node is the only non-empty child of . We call maximal if it cannot be extended by the parent of (either because is the root or because has two non-empty children). For each maximal singular path in , we remove from all proper descendants of that are not descendants of , together with their incident edges. Then, we add a new compressed edge between and . The resulting tree has nodes. Each internal node has one or four children.444According to our definition, the compressed quadtree may contain empty leaves, namely empty leaves that are children of nodes with at least two non-empty children. This empty leaves do not belong to any singular path. See Figure 4 (right) for an illustration. There are algorithms to compute in time and space (see, e.g. Har-Peled’s book [13, Theorem 2.9] or Buchin et al. for a version that does not need the floor function [4, Appendix A]).
We now describe how to map the candidate pairs from to candidate pairs in . A node from may appear as a node in or not. We let be the lowest ancestor node of (including ) in that appears also in . We call the upward projection of in . For a node that appears in , we denote by the set of all nodes in that project to . If is a leaf or has four children in , then . Otherwise, if has one child in , then contains the nodes of the maximal singular path that starts in , without the last vertex. Furthermore, for , we write the parent of in (we set , if is the root). We define the set of compressed candidate pairs for in as
[TABLE]
In other words, we obtain the compressed candidate pairs for a node in by taking the upward projections of all candidate pairs in where the first component projects to .
We can now describe our modified algorithm, Algorithm 3. Essentially, Algorithm 3 works in the same way as Algorithm 2: we go through the disks by decreasing order of priority, and for each disk , we simulate the growth process of by walking along the leaf-root path for the disk center in the compressed quadtree , while checking for elimination events with nearby disks of higher priority. There are two differences: first, instead of the candidate pairs of the current node , we now use the compressed candidate pairs to check for elimination events; second, the termination condition of the while-loop (line 7) is modified: instead of comparing with the time when first covers , we use , the time when first covers the box for any node in . This ensures that we do not miss an elimination event on a singular path starting at . Next, we argue that Algorithm 3 correctly computes the elimination sequence. Then, we will discuss an efficient implementation. The correctness for Algorithm 3 follows from essentially the same argument as for Algorithm 2.
Lemma 5.4**.**
Algorithm 3 correctly computes the elimination sequence.
Proof.
We prove that Algorithm 3 maintains the following invariant: after iterations of the for-loop, we have the correct elimination times for . Furthermore, for each node of , we have , and if there is a point in time when a node in is covered by the disk , , then (this is well defined, because the nodes along a singular path can be occupied by at most one disk).
The invariant holds for , because is set to in Line 6 and for all the nodes in , the value is initialized to , so that no elimination event will be detected in Line 10. The values on the leaf-root path of are all set to , as desired. Now, suppose that and that is eliminated by the disk , with . By Lemma 5.1, the pair is a candidate pair in . Furthermore, lies on the leaf-root path for in . By (***), it follows that is a compressed candidate pair in and that lies on the leaf-root path for in . By the inductive hypothesis, we have . Again by the inductive hypothesis and by the test in Line 10, we have throughout the while-loop. Thus, the while-loop will visit and consider the compressed candidate pair . At this point, Algorithm 3 will detect the elimination event and set to . After that, the test in Line 7 ensures that the remaining variables are set correctly. In particular, the algorithm does not overwrite any other such values from previous iterations. Thus, the invariant is maintained and the correctness of Algorithm 3 follows. ∎
Next, we discuss how to implement Algorithm 3 efficiently. First we must bound the number of compressed candidate pairs. For this, we need two closure properties for candidate pairs in : if two nodes in form a candidate pair, then so do their parents; and if two nodes form a candidate pair in which lies at a lower level than , then all the ancestors of up to the level of also form candidate pairs with . See Figure 6 for an illustration.
Lemma 5.5**.**
Let be nodes of such that and . Then, we have
- (i)
, i.e., the parents of and also form a candidate pair; and 2. (ii)
if , then for any ancestor of with , i.e., all the ancestors of up to the level of also form candidate pairs with .
Proof.
We must check properties () and (**) of a candidate pair. For (i), property () holds because
[TABLE]
where in the first and third inequality we used the fact that and and in the second inequality we used that is a candidate pair. Property (**) holds because
[TABLE]
since is a candidate pair. The argument for (ii) is analogous. Since is a subset of and since is a candidate pair, we have
[TABLE]
so property (*) holds. Furthermore, since and since is a candidate pair, we have
[TABLE]
which shows property (**). ∎
The next lemma provides a way to charge compressed candidate pairs in to candidate pairs in . More precisely, we show that each compressed candidate pair in can be obtained by taking a candidate pair with , and by projecting upwards; see Figure 7.
Lemma 5.6**.**
Let be two nodes in with . Then, there are two nodes in such that (i) , i.e., and form a candidate pair in ; (ii) , i.e., is not larger than ; and (iii) or , i.e., the compressed candidate pair is obtained by taking a candidate pair for or for and by projecting the other component upwards.
Proof.
Since , definition (***) implies that there are two nodes , in where (i) and form a candidate pair, i.e., ; (ii) the notation is such that is not larger than , i.e., ; and (iii) the upward projections of and (in the right order) give the compressed candidate pair , i.e., . We repeatedly apply Lemma 5.5(i) to , until we meet or , whichever happens first. By assumption, and are distinct, so all the parents along the way are also distinct, and Lemma 5.5(i) is applicable. See Figure 7 for an illustration.
Suppose we meet first. In this case, we set . Then, it follows that for some ancestor of in with . Since is encountered first, the upward projections of and in are the same, i.e., . Hence, the pair has all the desired properties.
Second, suppose we meet first. Consider the ancestor of that has the same size as . If appears on the path from to in , we set and . Otherwise, we set and . In either case, . Furthermore, by Lemma 5.5(ii), we have . Finally, the upward projections are maintained. Hence, again has all the desired properties. ∎
Now, we can bound the number of compressed candidate pairs with a simple charging argument.
Lemma 5.7**.**
The total number of compressed candidate pairs is .
Proof.
Let be a compressed candidate pair. We use Lemma 5.6 to charge to a pair with and .
Now, let be a node of . Every candidate pair with is charged at most twice, namely (potentially) by and by . By Lemma 5.2, there are candidate pairs with . Since has nodes, the claim follows. ∎
Now, we have enough tools to find all the compressed candidates in Line 9 efficiently.
Lemma 5.8**.**
During Algorithm 3, we can enumerate all compressed candidates for the nodes visited by the algorithm in total time and space .
Proof.
During preprocessing, we compute for each node in neighbor pointers to all nodes where contains a node with and . For each , there are such pointers (a simple volume argument), and they can be found in time and space by a top-down traversal.
Now suppose we want to enumerate the compressed candidate pairs for a node in . Let be such a candidate. By Lemma 5.6, we have either (i) for a candidate pair with or (ii) , where appears in and is a candidate pair in with .
To find the compressed candidate pairs of type (i), we enumerate all (regular) candidate pairs for , using the neighbor pointers for and its ancestors in a similar procedure as in Theorem 5.3. By Lemma 5.2, this takes time and no additional space if we process the compressed candidate pairs immediately without storing them. For compressed candidate pairs of type (ii), we must enumerate all nodes such that contains a node with and . The crucial observation is that by Lemma 5.5, these nodes form a connected subtree under each neighbor node of . Thus, we can find them by following the neighbor pointers for and by traversing each such subtree as long as a compressed candidate pair is found. We can check whether a node forms a compressed candidate pair with in by elementary calculations involving the floor function.555We can also do without the floor function if we slightly relax the notion of a compressed candidate pair. Thus, the time is proportional to the number of distinct compressed candidate pairs that are discovered. No additional space is necessary, because the compressed candidate pairs can be processed immediately. Since each node in is visited at most once by Algorithm 3, the result now follows from Lemma 5.7. ∎
The following theorem summarizes our result for this section.
Theorem 5.9**.**
The elimination sequence of disks can be computed in time and space, where .
Proof.
By Lemma 5.4, Algorithm 3 correctly computes the elimination sequence. The compressed quadtree can be constructed in time and space. This is also the time needed for the final sorting step. Since Algorithm 3 visits each node of at most once, and since has nodes, the time for the for-loop (without the time for computing the compressed candidates) is , by Lemma 5.7. It uses no additional space. Finally, by Lemma 5.8, the additional time for enumerating the compressed candidate pairs is , using space. The result follows. ∎
6 Lower bound
To complement our results, we provide a lower bound for finding elimination sequences in the algebraic decision tree model. Formann [9] argued that the weighted-closest pair problem has an lower bound in the algebraic decision tree model, by a reduction from the closest-pair-problem. Since finding the elimination order is a more general problem, this also implies an lower bound for our problem. Here, we provide a slightly stronger result by showing that the sorting problem reduces to finding elimination orders.
Theorem 6.1**.**
There is a reduction from the sorting problem to the elimination order problem. In particular, it takes at least time to find the elimination order of a set of growing disks or squares in the plane under the algebraic decision tree model.
Proof.
We show that the problem of sorting numbers can be reduced to finding the elimination order of disks in the plane. This implies an lower bound in the algebraic decision tree model.
Our reduction proceeds as follows: Suppose we are given numbers , to be sorted. Set . We define growing disks as follows: for , we center the disk at p_{i}=\big{(}2i+i^{2}\varepsilon,0\big{)} and give it the growth rate . For , we position the disk at with growth rate as in the input; see Figure 8 for an illustration. Observe that disk will be eliminated by disk at time , since for . Then, the elimination order of lets us deduce the reverse sorted order of . An analogous argument also applies to squares. ∎
We remark that Theorem 6.1 also shows that in general the problem does not become easier if we are interested only in the elimination order and not the exact elimination times.
7 Conclusion
We have presented the first truly subquadratic algorithm for the problem of computing the elimination order and elimination times of a sequence of growing disks in the plane. Our approach is very general and also applies to other shapes. However, it still falls short of reaching a near-linear time algorithm, except for the special case of growing cubes. Thus, the most pressing question remains: can we compute the elimination order of growing disks in the plane in time?
Our algorithm that uses compressed quadtrees comes close, but it depends on additional parameters of the input: if the growth rates vary wildly, or if the points are arranged unevenly, the running times may deteriorate. Perhaps a more careful handling of these inputs could enable us to avoid this dependence. It would also be interesting to see if and how the quadtree approach can be adapted to higher dimensions.
Finally, many further well-motivated variants of the problem are possible. For example, Castermans et al. [5] consider the setting where two touching disks are replaced by a new, common, disk, instead of one of them disappearing. It is a promising research direction to explore these variants and to see in how far our techniques are applicable or which new ideas are required.
Acknowledgments.
This work was initiated during the 20th Korean Workshop on Computational Geometry. The authors would like to thank the other participants for motivating and insightful discussions. We would also like to thank the anonymous reviewers for their close reading of the paper and for many helpful comments that significantly improved the presentation of the paper.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Pankaj K. Agarwal, Boris Aronov, and Micha Sharir. Computing envelopes in four dimensions with applications. SIAM Journal on Computing , 26(6):1714–1732, 1997.
- 2[2] Daniel Bahrdt, Michael Becher, Stefan Funke, Filip Krumpe, André Nusser, Martin Seybold, and Sabine Storandt. Growing balls in ℝ d superscript ℝ 𝑑 \mathbb{R}^{d} . In Proceedings of the 19th Workshop on Algorithm Engineering and Experiments (ALENEX) , pages 247–258, 2017.
- 3[3] Mark de Berg, Otfried Cheong, Marc van Kreveld, and Mark Overmars. Computational Geometry: Algorithms and Applications . Springer-Verlag, 2008.
- 4[4] Kevin Buchin, Maarten Löffler, Pat Morin, and Wolfgang Mulzer. Preprocessing imprecise points for Delaunay triangulation: Simplified and extended. Algorithmica , 61(3):674–693, 2011.
- 5[5] Thom Castermans, Bettina Speckmann, Frank Staals, and Kevin Verbeek. Agglomerative clustering of growing squares. In Proceedings of the 13th Latin American Theoretical Informatics Symposium (LATIN) , pages 260–274, 2018.
- 6[6] Bernard Chazelle. The Discrepancy Method. Randomness and complexity . Cambridge University Press, 2000.
- 7[7] Bernard Chazelle, Herbert Edelsbrunner, Michelangelo Grigni, Leonidas J. Guibas, John Hershberger, Micha Sharir, and Jack Snoeyink. Ray shooting in polygons using geodesic triangulations. Algorithmica , 12(1):54–68, 1994.
- 8[8] Bernard Chazelle, Herbert Edelsbrunner, Leonidas J. Guibas, and Micha Sharir. A singly exponential stratification scheme for real semi-algebraic varieties and its applications. Theoret. Comput. Sci. , 84(1):77–105, 1991.
