Point Location Lekcija 8 Sergio Cabello - - PowerPoint PPT Presentation

point location
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Outline

◮ a fundamental problem: point location ◮ solved using

  • trapezoidal map
  • RIC

Sergio Cabello RC – Point Location

slide-3
SLIDE 3

Problem statement

◮ given (a DCEL of) a Plane Straight Line Graph (PSLG) G,

preprocess G to answer the following queries efficiently:

  • input: a query point q
  • output: the face of G that contains q

◮ remarks:

  • ne dimension

in the plane sorting trapezoidal map searching point location quicksort RIC random BST history graph

Sergio Cabello RC – Point Location

slide-4
SLIDE 4

Results

◮ expected query time: O(log n) ◮ expected preprocessing time: O(n log n) ◮ expected space usage: O(n) ◮ can we do better?

  • deterministic algorithm with same time and space bounds
  • we will see it next time (board)
  • optimal in a suitable model of computation

Sergio Cabello RC – Point Location

slide-5
SLIDE 5

Trapezoidal map

◮ start with a PSLG G ◮ the trapezoidal map T (G) is obtained by drawing vertical edges

downward and upward from each vertex

G

T (G)

◮ we draw a bounding box around G so that there is no infinite

face, hence all faces of T (G) trapezoids (or triangles)

Sergio Cabello RC – Point Location

slide-6
SLIDE 6

General position assumptions

◮ the PSLG G is a set S of non–intersecting line segments ◮ no two endpoints have same x–coordinate

S T (S)

◮ for a general DCEL, simulate splitting at each vertex Sergio Cabello RC – Point Location

slide-7
SLIDE 7

Consequences

◮ each trapezoid ∆ of T (S) depends on

  • a bottom segment bottom(∆)
  • a top segment top(∆)
  • a left endpoint left(∆)
  • a right endpoint right(∆)

∆ right(∆) top(∆) bottom(∆) left(∆) ∆′ top(∆′) bottom(∆′) right(∆′) left(∆′)

Sergio Cabello RC – Point Location

slide-8
SLIDE 8

Neighbors

◮ two trapezoids are neighbors if and only if

they share a vertical edge

◮ by our general position assumption,

a trapezoid has at most 4 neighbors

Sergio Cabello RC – Point Location

slide-9
SLIDE 9

Data structure

◮ Augment a DCEL with extra information ◮ or simpler: just store adjacency relations from previous two slides

  • the endpoints of the segments in S are represented by their

coordinates

  • the segments in S are represented by their left and right

endpoints

  • each trapezoid ∆ of T (S) has pointers to

⋆ bottom(∆), top(∆) ⋆ left(∆), right(∆) ⋆ its (at most) 4 neighbors Sergio Cabello RC – Point Location

slide-10
SLIDE 10

Trapezoidal map

◮ T (G) has

  • O(n) vertices
  • O(n) edges
  • O(n) faces (=trapezoids)

◮ we use T (G) for point location ◮ point location in a trapezoidal map

  • construct trapezoidal map by RIC
  • use history graph to perform point location

Sergio Cabello RC – Point Location

slide-11
SLIDE 11

Point location in a PSLG G

◮ first compute T (G) and associated search structure by RIC ◮ then augment with pointers from each face of T (G) to the face

in G that contains it

  • use the edges bottom(∆) to identify the face of G that

contains it

◮ perform point location in T (G) ◮ find the corresponding face in G Sergio Cabello RC – Point Location

slide-12
SLIDE 12

RIC trapezoidal maps

Sergio Cabello RC – Point Location

slide-13
SLIDE 13

Preliminaries

◮ 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

bounding box

◮ each trapezoid ∆ stores a conflict list: list of segments whose

left endpoint is in ∆

  • initially, only one conflict list (for the interior face of the

bounding box) that gathers all the segments in S

  • keep a pointer from each s ∈ S to its conflicting trapezoid,

which is the interior face of the bounding box

Sergio Cabello RC – Point Location

slide-14
SLIDE 14

Conflict lists: example

s3 ∆′ s6 s2 s8 s5 s7 s4 s1 ∆ ∆′′

◮ L(∆) = {s5, s8} ◮ L(∆′) = {s6} ◮ L(∆′′) = {s7} Sergio Cabello RC – Point Location

slide-15
SLIDE 15

Idea

◮ at step i we maintain:

  • a representation of T (Si)
  • for each trapezoid ∆ of T (Si)

⋆ a conflict list L(∆) of pointers to all the segments in

S \ Si whose left endpoint is in ∆

  • for each s ∈ S \ Si

⋆ a pointer to the trapezoid ∆ of T (Si) that contains its

left endpoint

◮ then we insert si+1 and update this data structure Sergio Cabello RC – Point Location

slide-16
SLIDE 16

Inserting si

◮ si may cross several trapezoids of T (Si−1) ◮ each trapezoid is split into at most 4 trapezoids ◮ some trapezoids have to be merged

si

Sergio Cabello RC – Point Location

slide-17
SLIDE 17

Inserting si

◮ si may cross several trapezoids of T (Si−1) ◮ each trapezoid is split into at most 4 trapezoids ◮ some trapezoids have to be merged

si

Sergio Cabello RC – Point Location

slide-18
SLIDE 18

Inserting si

◮ si may cross several trapezoids of T (Si−1) ◮ each trapezoid is split into at most 4 trapezoids ◮ some trapezoids have to be merged

si

Sergio Cabello RC – Point Location

slide-19
SLIDE 19

Zone of si

◮ The zone of si in T (Si−1) is the union of all the cells that

intersect si.

si

◮ It is the union of all the trapezoids of T (Si−1) that are destroyed

when we insert si

Sergio Cabello RC – Point Location

slide-20
SLIDE 20

Zone of si

◮ It is the union of all the trapezoids in T (Si) that depend on si.

si

◮ It is the union of all the trapezoids created when we insert si Sergio Cabello RC – Point Location

slide-21
SLIDE 21

Updating the trapezoidal map

◮ we know which trapezoid in T (Si−1) contains the left endpoint

  • f si: this is the trapezoid that conflicts with si

◮ 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

slide-22
SLIDE 22

Updating the conflict information

◮ we also need to update the conflict lists ◮ non–inserted left endpoints move from destroyed trapezoids to

newly created trapezoids

◮ each destroyed trapezoid is contained in the union of 4 new

trapezoids

◮ so update can be done in time O(Xi), where Xi is the number of

left endpoints of non–inserted segments in the zone of si

◮ Xi is also the number of left endpoints in the trapezoids of T (Si)

that depend on si

Sergio Cabello RC – Point Location

slide-23
SLIDE 23

Estimation of E[ki]

◮ trapezoid ∆ ∈ T (Si) is a newly created trapezoid iff it depends

  • n si

◮ ∀s ∈ Si let

  • δ(∆, s) = 1 if ∆ depends on s
  • δ(∆, s) = 0 otherwise

◮ the number of trapezoids that depend on s is

  • ∆∈T (Si)

δ(∆, s)

Sergio Cabello RC – Point Location

slide-24
SLIDE 24

Estimation of E[ki]

◮ we use backward analysis ◮ we assume that Si is fixed ◮ then si can be any segment in Si with probability 1/i ◮ then

E[ki] = 1 i

  • s∈Si

 

  • ∆∈T (Si)

δ(∆, s)  

◮ we reverse the order of summation:

E[ki] = 1 i

  • ∆∈T (Si )

 

s∈Si

δ(∆, s)  

Sergio Cabello RC – Point Location

slide-25
SLIDE 25

Estimation of E[ki]

◮ What is:

  • s∈Si

δ(∆, s)

◮ this is the number of segments that ∆ depends on ◮ so it is at most 4 ◮ therefore

E[ki] ≤ 1 i

  • ∆∈T (Si)

4

◮ there are O(i) trapezoids in T (Si) so

E[ki] = 1 i O(i) = O(1)

Sergio Cabello RC – Point Location

slide-26
SLIDE 26

Estimation of Xi

◮ we also need to estimate Xi: number of non–inserted left

endpoints in zone of si

◮ backward analysis: Si is fixed ◮ let s ∈ S \ Si ◮ let ∆s be the trapezoid in T (Si) that contains the left endpoint

  • f segment s

◮ What is the probability that ∆s is newly created?

  • this is the probability that si is one of the (at most 4)

segments ∆s depends on

  • so it is at most 4/i

◮ so

E[Xi] ≤ 4(n − i) i

Sergio Cabello RC – Point Location

slide-27
SLIDE 27

Analysis

◮ let T(n) be the construction time ◮ then by linearity of expectation

E[T(n)] = O n

  • i=1

E[ki] + E[Xi]

  • ◮ so

E[T(n)] = O n

  • i=1

1 + n i

  • = O
  • n

n

  • i=1

1 i

  • = O(n log n)

◮ this is an expected time on worst case input Sergio Cabello RC – Point Location

slide-28
SLIDE 28

Point location data structure

Sergio Cabello RC – Point Location

slide-29
SLIDE 29

Preliminaries

◮ the history graph records the history of the RIC ◮ Similar as we did for modified Quicksort:

  • Quicksort ⇒ history graph ⇒ searching

◮ here:

  • RIC ⇒ history graph ⇒ point location

◮ for Quicksort, history graph was a tree

  • here it is a DAG: Directed Acyclic Graph

◮ expected preprocessing time: O(n log n) ◮ expected space usage: O(n) ◮ expected query time: O(log n) Sergio Cabello RC – Point Location

slide-30
SLIDE 30

Example (1)

s1 A B A′ B′ A Trapezoidal map B B′ A′ History graph (The root corresponds to the bounding box)

Sergio Cabello RC – Point Location

slide-31
SLIDE 31

Example (2)

s1 A B A Trapezoidal map History graph s2 B′ A′ B′ A′ A′ and B′ are deleted from the trapezoidal map but remain in the history graph B

Sergio Cabello RC – Point Location

slide-32
SLIDE 32

Update of the history graph

◮ connect each destroyed trapezoid to all the newly created

trapezoids that overlap it

◮ overlap means the interior intersect; not just touching along an

edge.

Sergio Cabello RC – Point Location

slide-33
SLIDE 33

Example (3)

s1 A B C D E G A B D C F E G B′ A′ s2 F

◮ the history graph is not a tree: two edges point to F ◮ it is a DAG Sergio Cabello RC – Point Location

slide-34
SLIDE 34

Example (4)

s1 A B G D E C s3 A B A′ B′ D C E F G s2 F

Sergio Cabello RC – Point Location

slide-35
SLIDE 35

Example (5)

s1 A B s3 I J K M N H A A′ B′ B F C D E G H I J L K M N s2 L F

Sergio Cabello RC – Point Location

slide-36
SLIDE 36

Analysis

◮ update time of DAG

  • in time proportional to the number of new trapezoids
  • in other words O(ki)
  • we have seen that E[ki] = O(1)
  • hence, building the DAG takes O(n) time overall
  • we also have to count O(n log n) time for the RIC

Sergio Cabello RC – Point Location

slide-37
SLIDE 37

Answering queries

◮ 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

the trapezoid that contains q

◮ O(1) time to go find appropriate descendant ◮ go down to this descendant and repeat the process Sergio Cabello RC – Point Location

slide-38
SLIDE 38

Analysis

◮ query time Q(n)

  • query point q
  • at step i, let ∆i be the trapezoid of T (Si) that contains q
  • each step where ∆i changes, we go down in the DAG
  • so the length of the search path for q is proportional to the

number of times ∆i changes

  • Q(n) is proportional to the length of the search path

Sergio Cabello RC – Point Location

slide-39
SLIDE 39

Analysis

◮ 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

E[Q(n)] = O n

  • i=1

4 i

  • = O(log n)

Sergio Cabello RC – Point Location

slide-40
SLIDE 40

Concluding remarks

◮ simple algorithm for a difficult problem ◮ can be implemented relatively easily ◮ however

  • analysis is not easy
  • not deterministic: some insertion orders can give

⋆ Θ(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