Point Location Prerocess a lanar, olygonal subdivision for oint location ueries. = (18, 11) Inut is a subdivision S of comlexity n, say, number of edges. uild a data structure on S so that for a uery oint = (x, y), we can find the face containing fast. Imortant metrics: sace and uery comlexity.
The Slab Method Draw a vertical line through each vertex. This decomoses the lane into slabs. In each slab, the vertical order of line segments remains constant. s5 D D s4 C C s3 s s1 Partition into slabs Slab 1 If we know which slab = (x, y) lies, we can erform a binary search, using the sorted order of segments.
The Slab Method To find which slab contains, we erform a binary search on x, among slab boundaries. second binary search in the slab determines the face containing. s5 D D s4 C C s3 s s1 Partition into slabs Slab 1 Thus, the search comlexity is O(log n). ut the sace comlexity is Θ(n ).
Otimal Schemes There are other schemes (kd-tree, uad-trees) that can erform oint location reasonably well, they lack theoretical guarantees. Most have very bad worst-case erformance. inding an otimal scheme was challenging. Several schemes were develoed in 70 s that did either O(log n) uery, but with O(n log n) sace, or O(log n) uery with O(n) sace. Today, we will discuss an elegant and simle method that achieved otimality, O(log n) time and O(n) sace [D. Kirkatrick 83]. Kirkatrick s scheme however involves large constant factors, which make it less attractive in ractice. Later we will discuss a more ractical, randomized otimal scheme.
Kirkatrick s lgorithm Start with the assumtion that lanar subdivision is a triangulation. If not, triangulate each face, and label each triangular face with the same label as the original containing face. If the outer face is not a triangle, comute the convex hull, and triangulate the ockets between the subdivision and CH. Now ut a large triangle abc around the subdivision, and triangulate the sace between the two. a b c
Modifying Subdivision y Euler e formula, the final size of this triangulated subdivision is still O(n). This transformation from S to triangulation can be erformed in O(n log n) time. a b c If we can find the triangle containing, we will know the original subdivision face containing.
Hierarchical Method Kirkatrick s method is hierarchical: roduce a seuence of increasingly coarser triangulations, so that the last one has O(1) size. Seuence of triangulations T 0, T 1,..., T k, with following roerties: 1. T 0 is the initial triangulation, and T k is just the outer triangle abc.. k is O(log n). 3. Each triangle in T i+1 overlas O(1) triangles of T i. Let us first discuss how to construct this seuence of triangulations.
uilding the Seuence Main idea is to delete some vertices of T i. Their deletion creates holes, which we re-triangulate. u v Vertex deletion and re triangulation We want to go from O(n) size subdivision T 0 to O(1) size subdivision T k in O(log n) stes. Thus, we need to delete a constant fraction of vertices from T i. critical condition is to ensure each new triangle in T i+1 overlas with O(1) triangles of T i.
Indeendent Sets Suose we want to go from T i to T i+1, by deleting some oints. Kirkatrick s choice of oints to be deleted had the following two roerties: [Constant Degree] Each deletion candidate has O(1) degree in grah T i. If has degree d, then deleting leaves a hole that can be filled with d triangles. When we re-triangulate the hole, each new triangle can overla at most d original triangles in T i. u v Vertex deletion and re triangulation
Indeendent Sets [Indeendent Sets] No two deletion candidates are adjacent. This makes re-triangulation easier; each hole handled indeendently. u v Vertex deletion and re triangulation
I.S. Lemma Lemma: Every lanar grah on n vertices contains an indeendent vertex set of size n/18 in which each vertex has degree at most 8. The set can be found in O(n) time. We rove this later. Let s use this now to build the triangle hierarchy, and show how to erform oint location. Start with T 0. Select an ind set S 0 of size n/18, with max degree 8. Never ick a, b, c, the outer triangle s vertices. Remove the vertices of S 0, and re-triangulate the holes. Label the new triangulation T 1. It has at most 17 18n vertices. Recursively build the hierarchy, until T k is reduced to abc. The number of vertices dros by 17/18 each time, so the deth of hierarchy is k = log 18/17 n 1 log n
Illustration n k o y z T m j l i c d b e h 0 1 a f g T x v w r u s t T 3 H J I T E C G D T4 (not shown) K T 4 H I J T 3 C D E G T r s t u v w x y z T 1 a b c d e f g h i j k l m n o T 0
The Data Structure Modeled as a DG: the root corresonds to single triangle T k. The nodes at next level are triangles of T k 1. Each node for a triangle in T i+1 has ointers to all triangles of T i that it overlas. To locate a oint, start at the root. If outside T k, we are done (exterior face). Otherwise, set t = T k, as the triangle at current level containing. T n k o m j h g l i a c d f 0 1 b e T y z x v w u t r s T 3 H J I T G E D C T4 (not shown) K T 4 H I J T 3 C D E G T r s t u v w x y z T 1 a b c d e f g h i j k l m n o T 0
The Search H J I E G D C x y w v u r s z t n m k j l i a c d b e o h g f K H I J C D E G r s t u v w x y z a b c d e f g h i j k l m n o Check each triangle of T k 1 that overlas with t at most 6 such triangles. Udate t, and descend the structure until we reach T 0. Outut t.
nalysis H J I G E D C y z x v w u t r s n o m k j h g l i a c d f b e K H I J C D E G r s t u v w x y z a b c d e f g h i j k l m n o Search time is O(log n) there are O(log n) levels, and it takes O(1) time to move from level i to level i 1. Sace comlexity reuires summing u the sizes of all the triangulations. Since each triangulation is a lanar grah, it is sufficient to count the number of vertices. The total number of vertices in all triangulations is n ( 1 + (17/18) + (17/18) + (17/18) 3 + ) 18n. Kirkatrick structure has O(n) sace and O(log n) uery time.
inding I.S. We describe an algorithm for finding the indeendent set with desired roerties. Mark all nodes of degree 9. While there is an unmarked node, do 1. Choose an unmarked node v.. dd v to IS. 3. Mark v and all its neighbors. lgorithm can be imlemented in O(n) time kee unmarked vertices in list, and reresenting T so that neighbors can be found in O(1) time. v
I.S. nalysis Existence of large size, low degree IS follows from Euler s formula for lanar grahs. triangulated lanar grah on n vertices has e = 3n 6 edges. Summing over the vertex degrees, we get deg(v) = e = 6n 1 < 6n. v We now claim that at least n/ vertices have degree 8. Suose otherwise. Then n/ vertices all have degree 9. The remaining have degree at least 3. (Why?) Thus, the sum of degrees will be at least 9 n + 3n = 6n, which contradicts the degree bound above. So, in the beginning, at least n/ nodes are unmarked. Each chosen v marks at most 8 other nodes (total 9 counting itself.) Thus, the node selection ste can be reeated at least n/18 times. So, there is a I.S. of size n/18, where each node has degree 8.
Traezoidal Mas randomized oint location scheme, with (exected) uery O(log n), sace O(n), and construction time O(n log n). The exectation does not deend on the olygonal subdivision. The bounds holds for any subdivision. It aears simler to imlement, and its constant factors are better than Kirkatrick s. The algorithm is based on traezoidal mas, or decomositions, also encountered earlier in triangulation.
Traezoidal Mas Inut a set of non-intersecting line segments S = {,,..., s n }. Query: given oint, reort the segment directly above. The region label can be easily encoded into the line segments. Ma is created by shooting a ray vertically from each vertex, u and down, until a segment is hit. In order to avoid degeneracies, assume that no segment is vertical. The resulting rays lus the segments define the traezoidal ma.
Traezoidal Mas Enclose S into a bounding box to avoid infinite rays. ll faces of the subdivision are traezoids, with vertical sides. Size Claim: If S has n segments, the ma has at most 6n + 4 vertices and 3n + 1 tras. Each vertex shoots one ray, each resulting in two new vertices, so at most 6n vertices, lus 4 for the outer box. The left boundary of each traezoid is defined by a segment endoint, or lower left corner of enclosing box. The corner of box acts as leftoint for one tra; the right endoint of any segment also for one tra; and left endoint of any segment for at most traezoids. So total of 3n + 1.
Construction Plane swee ossible, but not helful for oint location. Instead we use randomized incremental construction. Historically, invented for randomized segment intersection. Point location an intermediate roblem. Start with outer box, one traezoid. Then, add one segment at a time, in an arbitrary, not sorted, order. / s / / i efore fter inserting s
Construction Let S i = {,,..., s i } be first i segments, and T i be their traezoidal ma. Suose T i 1 built, and we add s i. ind the traezoid containing the left endoint of s i. Defer for now: this is oint location. Walk through T i 1, identifying traezoids that are cut. Then, fix them u. ixing u means, shoot rays from left and right endoints of s i, and trim the earlier rays that are cut by s i. / s / / i efore fter inserting s
nalysis Observation: inal structure of tra ma does not deend on the order of segments. (Why?) Claim: Ignoring oint location, segment i s insertion takes O(k i ) time if k i new traezoids created. Proof: Each endoint of s i shoots two rays. dditionally, suose s i interruts K existing ray shots, so total of K + 4 rays need rocessing. If K = 0, we get exactly 4 new traezoids. or each interruted ray shot, a new traezoid created. With DCEL, udate takes O(1) er ray. efore fter
Worst Case In a worst-case, k i can be Θ(i). This can haen for all i, making the worst-case run time n i=1 i = Θ(n ). Using randomization, we rove that if segments are inserted in random order, then exected value of k i is O(1)! So, for each segment s i, the exected number of new traezoids created is a constant. igure below shows a worst-case examle. How will randomization hel? n/ + 1 n 1 n/
Randomization Theorem: ssume,,..., s n is a random ermutation. Then, E[k i ] = O(1), where k i traezoids created uon s i s insertion, and the exectation is over all ermutations. Proof. 1. Consider T i, the ma after s i s insertion.. T i does not deend on the order in which segments,..., s i were added. 3. Reshuffle,..., s i. What s the robability that a articular s was the last segment added? 4. The robability i/i. 5. We want to comute the number of traezoids that would have been created if s were the last segment. s The traezoids that deend on s The segments that the traezoid deends on.
Proof Say traezoid deends on s if would be created by s if s were added last. Want to count traezoids that deend on each segment, and then find the average over all segments. Define δ(, s) = 1 if deends on s; otherwise, δ(, s) = 0. s The traezoids that deend on s The exected comlexity is E[k i ] = 1 ix s S i The segments that the traezoid deends on. Xδ(, s) T i Some segments create a lot of traezoids; others very few. X X Switch the order of summation: E[k i ] = 1 δ(, s) i s S i T i
Proof s The segments that the traezoid The traezoids that deend on s deends on. Now we are counting number Xof segments X each traezoid deents on. E[k i ] = 1 δ(, s) i s S i T i This is much easier each deends on at most 4 segments. To and bottom of defined by two segments; if either of them added last, then comes into existence. Left and right sides defined by two segments endoints, and if either one added last, is created. Thus,Ps S δ(, s) 4. i T i X has O(i) traezoids, so E[k i ] = 1 1 4 = i i 4 T i = 1 O(i) = O(1). i T i End of roof.
Point Location Like Kirkatrick s, oint location structure is a rooted directed acyclic grah. To uery rocessor, it looks like a binary tree, but subtree may be shared. Tree has two tyes of nodes: x-node: contains the x-coordinate of a segment endoint. (Circle) y-node: ointer to a segment. (Hexagon) leaf for each trazedoid. 1 C D 1 E G 1 C D 1 E G
Point Location Children of x-node corresond to oints lying to the left and right of x coord. Children of y-node corresond to sace below and above the segment. y-node searched only when uery s x-coordinate is within segment s san. Examle: uery in region D. 1 C D 1 E G 1 C D 1 E G Encodes the tra decomosition, and enables oint location during the construction as well.
uilding the Structure Incremental construction, mirroring the traezoidal ma. When a segment s added, modify the tree to account for changes in traezoids. Essentially, some leaves will be relaced by new subtrees. Like Kirkatrick s, each old traezoid will overla O(1) new traezoids. 1 C D 1 E G 1 C D 1 E G Each traezoid aears exactly once as a leaf. or instance,.
dding a Segment Consider adding segment s 3. 1 C D 1 E G 1 C D 1 E G K 1 1 s I 1 s 3 3 3 N L M H J H 1 1 s 3 s 3 3 s 3 s 3 3 M N I J K L
dding a Segment Changes are highly local. If segment s asses entirely through an old traezoid t, then t is relaced by two tras t, t. During search, we need to comare uery oint to s to decide above/below. So, a new y-node added which is the arent of t and t. If an endoint of s lies in t, then we add a x-node to decide left/right and a y-node for the segment. K 1 1 s I 1 s 3 3 3 N L M H J H 1 1 s 3 s 3 3 s 3 s 3 3 M N I J K L
nalysis Sace is O(n), and uery time is O(log n), both in exectation. Exected bound deends on the random ermutation, and not on the choice of inut segments or the uery oint. The data structure size number of traezoids, which is O(n), since O(1) exected number of tras created when a new segment inserted. In order to analyze uery bound, fix a uery. We consider how moves incrementally through the traezoidal ma as new segments are inserted. Search comlexity number of traezoids encountered by.
Search nalysis Let i be traezoid containing after insertion of ith segment. If i = i 1 then new insertion does not affect s traezoid. (E.g. and s 3 s insertion.) If i i 1, then new segment deleted s traezoid, and needs to locate itself among the (at most 4) new tras. could fall 3 levels in the tree. E.g. C falling to J after s 3 s insertion. K 1 1 s I 1 s 3 3 3 N L M H J H 1 1 s 3 s 3 3 s 3 s 3 3 M N I J K L
Search nalysis Let P i be robability that i i 1, over all random ermutation. Since can dro 3 levels, exected search ath length is n i=1 3P i. We will show that P i 4/i. That will imly that exected search ath length is n n 4 3 i = 1 1 = 1 ln n i i=1 i=1 Why is P i 4/i? Use backward analysis. The traezoid i deends on at most 4 segments. The robability that ith segment is one of these 4 is at most 4/i. 1 C D 1 E G 1 C D 1 E G
inal Remarks Exectation only says that average search ath is small. It can still have large variance. The traezoidal ma data structure has bounds on variance too. See the textbook for comlete analysis. Theorem: or any λ > 0, the robability that deth of the randomized seach structure exceeds 3λ ln(n + 1) is at most (n + 1) λ ln 1.5 3 More careful analysis can rovide better constants for the data structure.