Point Location
Lekcija 8 Sergio Cabello sergio.cabello@fmf.uni-lj.si FMF Univerza v Ljubljani Edited from slides by Antoine Vigneron
Sergio Cabello RC – Point Location
Point Location Lekcija 8 Sergio Cabello - - PowerPoint PPT Presentation
Point Location Lekcija 8 Sergio Cabello sergio.cabello@fmf.uni-lj.si FMF Univerza v Ljubljani Edited from slides by Antoine Vigneron Sergio Cabello RC Point Location Outline a fundamental problem: point location solved using
Sergio Cabello RC – Point Location
◮ a fundamental problem: point location ◮ solved using
Sergio Cabello RC – Point Location
◮ given (a DCEL of) a Plane Straight Line Graph (PSLG) G,
◮ remarks:
Sergio Cabello RC – Point Location
◮ expected query time: O(log n) ◮ expected preprocessing time: O(n log n) ◮ expected space usage: O(n) ◮ can we do better?
Sergio Cabello RC – Point Location
◮ start with a PSLG G ◮ the trapezoidal map T (G) is obtained by drawing vertical edges
◮ we draw a bounding box around G so that there is no infinite
Sergio Cabello RC – Point Location
◮ the PSLG G is a set S of non–intersecting line segments ◮ no two endpoints have same x–coordinate
◮ for a general DCEL, simulate splitting at each vertex Sergio Cabello RC – Point Location
◮ each trapezoid ∆ of T (S) depends on
Sergio Cabello RC – Point Location
◮ two trapezoids are neighbors if and only if
◮ by our general position assumption,
Sergio Cabello RC – Point Location
◮ Augment a DCEL with extra information ◮ or simpler: just store adjacency relations from previous two slides
⋆ bottom(∆), top(∆) ⋆ left(∆), right(∆) ⋆ its (at most) 4 neighbors Sergio Cabello RC – Point Location
◮ T (G) has
◮ we use T (G) for point location ◮ point location in a trapezoidal map
Sergio Cabello RC – Point Location
◮ first compute T (G) and associated search structure by RIC ◮ then augment with pointers from each face of T (G) to the face
◮ perform point location in T (G) ◮ find the corresponding face in G Sergio Cabello RC – Point Location
Sergio Cabello RC – Point Location
◮ compute a random permutation (s1, s2, . . . sn) of S ◮ we denote Si = {s1, s2 . . . si} for all i ≤ n ◮ initialize the data structure: DCEL or adjacency relations for the
◮ each trapezoid ∆ stores a conflict list: list of segments whose
Sergio Cabello RC – Point Location
◮ L(∆) = {s5, s8} ◮ L(∆′) = {s6} ◮ L(∆′′) = {s7} Sergio Cabello RC – Point Location
◮ at step i we maintain:
⋆ a conflict list L(∆) of pointers to all the segments in
⋆ a pointer to the trapezoid ∆ of T (Si) that contains its
◮ then we insert si+1 and update this data structure Sergio Cabello RC – Point Location
◮ si may cross several trapezoids of T (Si−1) ◮ each trapezoid is split into at most 4 trapezoids ◮ some trapezoids have to be merged
Sergio Cabello RC – Point Location
◮ si may cross several trapezoids of T (Si−1) ◮ each trapezoid is split into at most 4 trapezoids ◮ some trapezoids have to be merged
Sergio Cabello RC – Point Location
◮ si may cross several trapezoids of T (Si−1) ◮ each trapezoid is split into at most 4 trapezoids ◮ some trapezoids have to be merged
Sergio Cabello RC – Point Location
◮ The zone of si in T (Si−1) is the union of all the cells that
◮ It is the union of all the trapezoids of T (Si−1) that are destroyed
Sergio Cabello RC – Point Location
◮ It is the union of all the trapezoids in T (Si) that depend on si.
◮ It is the union of all the trapezoids created when we insert si Sergio Cabello RC – Point Location
◮ we know which trapezoid in T (Si−1) contains the left endpoint
◮ we proceed from left to right and update the trapezoidal map ◮ everything is done within the zone of si ◮ we sweep from left to right ◮ only two trapezoids intersect the sweep line at any time ◮ let ki be the number of trapezoids in T (Si) that depend on si ◮ there are at most ki events ◮ so the update can be done in O(ki) time Sergio Cabello RC – Point Location
◮ we also need to update the conflict lists ◮ non–inserted left endpoints move from destroyed trapezoids to
◮ each destroyed trapezoid is contained in the union of 4 new
◮ so update can be done in time O(Xi), where Xi is the number of
◮ Xi is also the number of left endpoints in the trapezoids of T (Si)
Sergio Cabello RC – Point Location
◮ trapezoid ∆ ∈ T (Si) is a newly created trapezoid iff it depends
◮ ∀s ∈ Si let
◮ the number of trapezoids that depend on s is
Sergio Cabello RC – Point Location
◮ we use backward analysis ◮ we assume that Si is fixed ◮ then si can be any segment in Si with probability 1/i ◮ then
◮ we reverse the order of summation:
s∈Si
Sergio Cabello RC – Point Location
◮ What is:
◮ this is the number of segments that ∆ depends on ◮ so it is at most 4 ◮ therefore
◮ there are O(i) trapezoids in T (Si) so
Sergio Cabello RC – Point Location
◮ we also need to estimate Xi: number of non–inserted left
◮ backward analysis: Si is fixed ◮ let s ∈ S \ Si ◮ let ∆s be the trapezoid in T (Si) that contains the left endpoint
◮ What is the probability that ∆s is newly created?
◮ so
Sergio Cabello RC – Point Location
◮ let T(n) be the construction time ◮ then by linearity of expectation
n
◮ this is an expected time on worst case input Sergio Cabello RC – Point Location
Sergio Cabello RC – Point Location
◮ the history graph records the history of the RIC ◮ Similar as we did for modified Quicksort:
◮ here:
◮ for Quicksort, history graph was a tree
◮ expected preprocessing time: O(n log n) ◮ expected space usage: O(n) ◮ expected query time: O(log n) Sergio Cabello RC – Point Location
Sergio Cabello RC – Point Location
Sergio Cabello RC – Point Location
◮ connect each destroyed trapezoid to all the newly created
◮ overlap means the interior intersect; not just touching along an
Sergio Cabello RC – Point Location
◮ the history graph is not a tree: two edges point to F ◮ it is a DAG Sergio Cabello RC – Point Location
Sergio Cabello RC – Point Location
Sergio Cabello RC – Point Location
◮ update time of DAG
Sergio Cabello RC – Point Location
◮ the query point q is given by its coordinates ◮ if the current node is a leaf, then we are done ◮ otherwise, one of the ≤ 4 descendants of the current trapezoid is
◮ O(1) time to go find appropriate descendant ◮ go down to this descendant and repeat the process Sergio Cabello RC – Point Location
◮ query time Q(n)
Sergio Cabello RC – Point Location
◮ how many times does ∆i change? ◮ we use backward analysis: Si is fixed ◮ what is the probability that ∆i is new? ◮ this is equal to the probability that ∆i depends on si ◮ ∆i depends on ≤ 4 segments ◮ so this probability is ≤ 4/i ◮ thus
Sergio Cabello RC – Point Location
◮ simple algorithm for a difficult problem ◮ can be implemented relatively easily ◮ however
⋆ Θ(n2) construction time ⋆ Θ(n2) space usage ⋆ Θ(n) query time ◮ it can be proven that the time bounds hold with high probability ◮ in practice, like quicksort, outperforms deterministic equivalents Sergio Cabello RC – Point Location