it is a data structure that can be used to solve a variety ...matya/courses/go08/chapter9_1.pdf ·...

26
It is a data structure that can be used to solve a variety of proximity problems. We will show how using WPS we can find in o(nlogn) time a t-spanner with o(n) edges for any given set of n points in R d and t > 1. with o(n) edges for any given set of n points in R d and t > 1.

Upload: others

Post on 15-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

It is a data structure that can be used to solve a variety of proximity problems.

We will show how using WPS we can find in o(nlogn) time a t-spanner with o(n) edges for any given set of n points in Rd and t > 1.with o(n) edges for any given set of n points in Rd and t > 1.

Page 2: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

DefinitionLet s > 0 be a real number and A, B are two finite sets of

points in Rd.

A and B are well separated with respect to s if there are to disjoint d-dimensional balls Ca and Cb such that:to disjoint d-dimensional balls Ca and Cb such that:

� Ca and Cb have the same radius.

� Ca contains the axes parallel bounding box R(A) of A.

� Cb contains the axes parallel bounding box R(B) of B.

� The distance between Ca and Cb is greater than or equal to s times the radius of Ca.

Page 3: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Lemma 1.2� Let p, p` be any two points from A.

� Let q, q` be any two points from B.

� |pp`| ≤ (2/s)|pq|

|p`q`| ≤ (1 + 4/s)|pq|� |p`q`| ≤ (1 + 4/s)|pq|

Page 4: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Proof:Let r be the radius of the balls Ca and Cb containing A

and B, and the distance between them is greater or equal to s*r.

We know that |pp`|≤2r and |pq|≥s*r.We know that |pp`|≤2r and |pq|≥s*r.

Hence we get that |pp`| ≤(2/s)|pq|.

In a symmetric way |qq`| ≤(2/s)|pq|.

|p`q`| ≤|pp`|+|pq|+|qq`| ≤ (triangle inequality).

(2/s)|pq|+|pq|+(2/s)|pq| = (1+4/s)|pq|

Page 5: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Well separated pair decomposition

(WSPD) definition:Let S be a set of n points in Rd, and let s > 0 be a real

number. A WSPD for S in respect to s is a sequence

{A1,B1},{A2,B2},…,{Am, Bm} of pairs of nonempty subsets of S, for some integer m such that:of S, for some integer m such that:

� For each 1≤i≤m, Ai and Bi are well separated with respect to s.

� For any two distinct points p and q, there is exactly one index 1≤i≤m such that p Ai and q Bi or the oposite.

� The integer m is called the size of the WSPD.∈ ∈

Page 6: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

� Is there a WSPD for any set S?

� YES

� We will show an algorithm that constructs a WSPD of size o(n) in o(nlogn) time, for any set S and for every size o(n) in o(nlogn) time, for any set S and for every separation ratio s>0.

� But what is it good for?

� Some motivation: we will now show a way to get a t-spanner:

Page 7: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Basic spanner construction:1. Construct a WSPD with separation ratio s>4.

2. Take one (arbitrary) edge for each pair of the decomposition.

Now we have a t-spanner with t=(s+4)/(s-4)

(hence s=4(t+1)/(t-1))

Page 8: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Proof:We will show by induction on the distance |pq| in the

sorted sequence of distances in S, that the graph G we got from using the algorithm has a t-spanner path between p and q.between p and q.

If |pq|=0 the claim holds.

The induction assumption will be: for two points x and y from S such that |xy|<|pq|, the graph G contains a t-spanner path between x and y.

We know there is a pair {Ai,Bi} such that (i) p is in Ai and q is in Bi or (ii) p is in Bi and q is in Ai.

Page 9: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Proof (cont.)Lets assume without loss of generality that (i) holds.

Let ai and bi be the representatives takes from Ai and Bi respectively. By lemma 1.2 we know that

|pa |≤(2/s)|pq|≤|pq| (because s>4). Therefore there is a |pai|≤(2/s)|pq|≤|pq| (because s>4). Therefore there is a t-spanner path P1 in G between p and ai. In the same way we know there is a t-spanner path P2 between q and bi. Let P=P1(ai,bi)P2 a path between p and q. denote L as its length

Page 10: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Proof(cont2)L ≤ t|pai|+|aibi|+t|biq|

By lemma 1.2 we know |aibi|≤(1+4/s)|pq|

Combining it with |pai|≤(2/s)|pq| and |biq| ≤(2/s)|pq|

We get L ≤ ((4(t+1)/s)+1)|pq| = t|pq|We get L ≤ ((4(t+1)/s)+1)|pq| = t|pq|

Page 11: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Split treeObservation: a hyper rectangle (axes parallel) is the

Cartesian product of d closed intervals:

R = [l1,r1]x[l2,r2]x…x[ld,rd]

Denote L (R) as the maximal side length of the Denote Lmax(R) as the maximal side length of the rectangle and Lmin(R) as the minimum.

Denote h(R) as the center of the largest interval in R.

Page 12: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Split tree definitionR(S) is the bounding box of the set S.

The split tree for S is a binary tree containing the points of S in its leaves.

The split tree is used to find WSPD.The split tree is used to find WSPD.

Here is an algorithm for constructing a split tree in Ѳ(n2):

Page 13: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Split tree construct algo #1:splitTree(S,R)

If |S|=1

then create a new node u;

R(u):=R(S)

R0(u):=R

store the only point in S in u and return u.

Else

compute R(S) and compute index I such that L (R(S))=L (R(S))compute R(S) and compute index I such that Lmax(R(S))=Li(R(S))

let H be the hyper plane with the equation xi=h(R(S))

using H, split R into two hyperrectangles R1 and R2

S1:=S R1 (S1 isn’t empty)

S2:=S\S1 (S1 isn’t empty)

v:=splitTree(S1,R1)

w:=splitTree(S2,R2)

create node u

R(u):=R(S)

R0(u):=R

v and w will be the left and right child of u

return u

end

I

Page 14: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Lemma 3.1� Lmin(R0(u))≥(1/2)Lmax(R(∏(u)))

Page 15: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Split tree construct algo #2:Definition:

Partial split tree (PST) is defined the same as split tree, except that subsets represented by the leaves may have size larger than 1 (up to n/2).size larger than 1 (up to n/2).

Page 16: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Algorithm partialSplitTree(S, R, (LSi)1≤i≤d)Input

I1: a set S of n points and a hyperrectangle R that contains the bounding box R(S).

I2: A collection of doubly linked-lists (LSi)1≤i≤d, where LSi contains the points of S sorted in a non decreasing order of their i-th coordinate.non decreasing order of their i-th coordinate.

I3: The d lists are connected by cross-pointers.

Output

O1: A PST T for S, such that each leaf u corresponds to a subset Su of size at most n/2.

O2: Each node u of T stores R(u) and R0(u) like in a regular split tree.

O3: Each leaf u stores the following additional information:

O3.1: A collection of double linked-lists LSiu

1≤i≤d such that Lsiu contains the points of Su

sorted in a non decreasing order of their i-th coordinate.

O3.2: The d lists Lsiu are connected by cross pointers.

Page 17: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Partial split tree algorithmThe algorithm consists of 6 steps:

Step 1:� Make copies CLSi for all the double linked-lists Lsi.

� For each 1≤i≤d, add cross pointers between Lsi and CLSi.� For each 1≤i≤d, add cross pointers between Lsi and CLSi.

� Size:=n

� Create a node u, which will be the root of the final PST.

� R0(u):=R

� Rename S to Su.

� For each 1≤i≤d, rename the lists Lsi to Lsiu.

� Goto step 2

Page 18: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Step 2If (size > (n/2)) goto step 3

For each 1≤i≤d walk along the list Lsiu.

For each point z in the list, follow the cross pointer to its occurrence in CLS and store in this to its occurrence in CLSi and store in this occurrence a pointer to node u.

Goto step 6

Page 19: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Step 3Using the given lists compute the bounding box R(Su).

R(u) := R(Su)

Compute index I such that Lmax(R(S))=Li(R(S)) and let H be the hyper plane with the equation xi=h(R(S)).

p:= first point of Lsiu.

p` := successor of p in Lsiu.

q:= last point of Lsiu.q:= last point of Lsi .

q`:= predecessor of q in Lsiu.

size`:=1

While p`≤ h(R(u)) and q`≥h(R(u))

p:=p`

p` := successor of p in Lsiu.

q:=q`

q`:= predecessor of q in Lsiu.

size`:=size`+1

If p`>h(R(u)) goto step 4

Else goto step 5

Page 20: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Step 4Create new nodes v and w and make them the left and right children of u.

Using the hyperplane H, split R into 2 hyperrectangles R1 and R2.

R0(v):=R1 ; R0(w):=R2

Starting at the first element, walk along the list Lsiu, until you reach p.

For every point z you encounter (including p) do:

4.1 from the occurrence of z in Lsiu, follow cross pointers in all lists CLSj,

store there a pointer to node v.

4.2 follow the cross pointers to all the lists Lsju (j≠i) and delete z from

these lists.

4.3 delete z from Lsiu.

u:=w ; size:=size-size`

Goto step 2

Page 21: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Step 5:This step is symmetrical to step 4 (q instead of p) and

right instead of left and go backwards on the lists instead of forward.

Page 22: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Step 6:For each leaf u of T, initialize empty lists Lsj

u.

For each j walk along the copy CLSj of the original list. For each point z in the copy, follow the pointer to the leaf u of T for which z is in S .to the leaf u of T for which z is in Su.

Add this point to the end of the list Lsju.

Create cross pointers between the lists Lsju.

Compute for each leaf u in T the bounding box R(Su) and assign it to R(u). The bounding box can be easily computed

by looking at the first and last items in Lsju 1≤j≤d

Page 23: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Lemma 3.2The algorithm above for computing partial split tree,

satisfies conditions o1,o2,o3.1,o3.2 and its running time is o(n).

Proof:Proof:

The correctness of the algorithm can be deduced from the way the tree is built.

Page 24: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Time complexity:Time of steps 1-5 is proportional to n + ∑u|Su|

Where the summation is taken over all leaves u of the tree. The sets Su are a partition of S, so the sum is exactly n.exactly n.

Step 6 taken o(n)

Page 25: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

FastSplitTree(S,R)If n=1, proceed as in the original split tree algo.

Lets assume that n>1:

� Sort the points d times to create (LSi)1≤i≤d and create cross pointers (preprocessing step).cross pointers (preprocessing step).

� Run partialSplitTree(S, R, (LSi)1≤i≤d).

� For each leaf u in the tree recursively call fastSplitTree(Su,R0(u))

Page 26: It is a data structure that can be used to solve a variety ...matya/Courses/GO08/Chapter9_1.pdf · Well separated pair decomposition (WSPD) definition: Let S be a set of n points

Time complexity:� The running time of the algorithm besides the

preprocessing will be denoted with T(n)

� T(n) = o(n) + ∑(T|Su|)

� Since each subset Su has size of at most n/2, and these � Since each subset Su has size of at most n/2, and these subsets are partitions of S, T(n) = o(nlogn)