Efficient Partition Trees Jiri Matousek Presented By Benny Schlesinger Omer Tavori 1
Simplex Range Searching Simplex range searching: We preprocess a set P of n points in so that, given any query region , the points in P can be counted or reported efficiently. Let's assume that the query region is a simple polygon; if it is not, we can always approximate it (by triangulation). 2
Simplex Range Searching We have arrived at the triangular range searching problem: given a set P of n points in the plane, count the points from P lying in a query triangle delta. Let’s first look at a simpler version of this problem, where the query triangle degenerates into a half plane (simply a query line). Extending the simpler version to the original problem is just looking at 3 lines. 3
Half plane query example 4
How do we solve the simplex range searching problem? We will use Partitions Trees 5
Partitions Trees vs. Cutting Trees Query Time Storage Construction Time Data Structure Cutting Trees Partitions Trees 6
Partitioning Point Sets A simplicial partition for a set P of n points in the plane is a collection := where the Pi are disjoint subsets of P whose union is P and i is a triangle containing Pi. The subsets Pi are called classes. We do not require the triangles to be disjoint. 7
Simplicial Partition 8
We say that a line h crosses a triangle if h intersects the interior of . A crossing number of a line h with respect to is the number of triangles crossed by h. In our example the crossing number of h is 2. 9
Simplicial Partition The crossing number of is the maximum crossing number over all possible lines. In the last figure you can find lines that intersect four triangles, but no line intersects all five. 10
Fine Simplicial Partition We say that a simplicial partition is fine if s |Pi|< 2s for a given s. In fine simplicial partitions none of the classes contains more than twice the average number of points of the classes. (If there are r classes and n points The average number of points in class is n/r = s) 11
Simplicial Partition If a triangle , of the partition is not crossed by the line h, then its class p, either lies completely in h, or it is completely disjoint from h (i.e. either completely above or below the line) In our example, if we queried with l+, the half- plane lying above l, we would have to recourse on two of the five classes. 12
The Partition Theorem It is always possible to find a simplicial partition with crossing number The partition Theorem: For a set P of n points in the plane, and a parameter r with 1 r n, a fine simplicial partition of size r and crossing number can be constructed in time O(n). 13
-Cutting cutting : A cutting is a collection of closed triangles with disjoint interiors, whose union is the whole plane. The size of a cutting is the number of its triangles. -cutting: Let H be a collection of n lines and let be a cutting. For a triangle , let denote the collection of lines of H intersecting . A cutting is an -cutting for H provided that 14
-cutting for weighted collection of lines A weighted collection of lines is a pair (H, w), where H is a collection of lines and is a weight function. A Cutting is an -cutting for (H,w), provided that, for every triangle : 15
The Partition Theorem In order to prove the partition theorem will use two lemmas. In the first lemma we will use the cutting theorem. Let us remind what is the cutting theorem. 16
The cutting theorem 17
Lemma 1 Let P be an n-point set in, let s be an integer parameter, 2 s < n, set r = n/s. and let H be a set of lines. Then there exists a simplicial partition for P, whose classes Pi satisfy s |Pi| < 2s for every i and that the crossing number of every line of H relative to is 18
Lemma 1: Building the Partition We inductively construct the disjoint sets Pi and i. Suppose that P1,…Pi have already been constructed and set Pi'=Pi-(P1 ,…, Pi) If |Pi|' < 2s we set Pi+1 = Pi', i+1 = R2. m = i+1 and := {(P1, 1),…,(Pm, m)} which finishes the construction. Otherwise Let ni = |Pi'| >= 2s. 19
Lemma 1: Finding a cutting using weights How do we find Pi+1 and i+1? We will find them by building a cutting for weighted collection of lines. For a line h H let ki(h) denote the number of triangles among 1,…, i (the triangles that are already in the partition) that are crossed by h. For every h H let. we also define a weighted collection (H,wi). 20
Lemma 1: Finding a cutting using weights At the first iteration: h H Notice that if a line h intersects i-1 at the next iteration: 21
Lemma 1: Finding a cutting using weights The intuition: While building the cutting we will try to avoid constructing triangles that are crossed by lines with “heavy” weights. (One of these triangles will be chosen to be a triangle in the simplicial partition.) 22
Lemma 1: Constructing A (1/ri)-cutting 23
Lemma 1: Constructing A (1/ri)-cutting 24
Lemma 1: Constructing A (1/ri)-cutting 25
Lemma 1: Constructing A (1/ri)-cutting 26
Lemma 1: Constructing A (1/ri)-cutting 27
Lemma 1: choosing i 28
Lemma 1: choosing i 29
Lemma 1: choosing i 30
Lemma 1: Updating The Weights 31
Lemma 1: Constructing a new Cutting 32
Lemma 1: Constructing a new Cutting 33
Lemma 1: Constructing a new Cutting 34
Lemma 1: Finding Pi+1 and i+1 We want to find a triangle i+1 which will hold the class Pi+1. Don’t forget that we want at least s points in Pi+1. Currently we have ni points left. 35
Lemma 1: Finding Pi+1 and i+1 According to the cutting theorem we know that we have a cutting with triangles. By the pigeonhole principle, One of the triangles in the cutting will have at least = s points. This triangle will be i+1. We choose some s points from i+1 to be Pi+1 in the partition. 36
Creating The Partition Algorithm 37
Lemma 1: Finding The Crossing Number Of The Partition We want to show that the crossing number of every line h in H relative to our partition is: 38
Lemma 1: Finding The Crossing Number Of The Partition 39
Lemma 1: Finding The Crossing Number Of The Partition 40
Lemma 1: Finding The Crossing Number Of The Partition 41
Lemma 1: Finding The Crossing Number Of The Partition 42
Lemma 2: The Test Set Lemma For an n-point set P and a parameter r, there exists set H of at most r lines, s.t, for any simplicial partition for P satisfying |Pi| s for i, the following holds: if k0 is the maximum crossing number of lines of H relative to the partition, then the crossing number of the partition is bounded by: 43
The cutting theorem Now that we can use the two lemmas we can easily prove the cutting theorem. Given an n-point set P in the plane, an integer parameter 2 <= s < n, and r = n/s. In order to obtain the desired simplicial partition, we first use lemma 2. We get a set H of at most r lines. 44
The cutting theorem Second we use lemma 1, obtaining a simplicial partition , whose classes have size between s and 2s, and such that the crossing number of any line of H is at most: By the property of H guaranteed by the Test Set Lemma the crossing number of is at most: 45
46 Lemma 2 Test-Set Lemma
47 Test-Set Lemma (cont.) Why Test-Set? We will show that we can literally find a “small” set of lines as stated, that is, a test-case of lines that ensures a certain crossing number for any partition whose classes’ sizes is no less than a certain bound, s.
48 Test-Set Lemma – proof
49 Test-Set Lemma (cont.) Primal plane – Dual plane
50 Test-Set Lemma (cont.)
51 Primal Plane – Dual Plane h Primal plane Dual plane Every point in the zone of h is either above two lines and below one line (or vice- versa), thus each point corresponds (in the dual plane) to a line above two points and below one (or vice-versa), hence, cutting the triangle.
52 Primal Plane – Dual Plane
53 Test-Set Lemma (cont.)
Application 54
Select In Half Plane Algorithm 55 This algorithm is quite simple. It merely uses the recursive nature of the Partition tree to gather all of the points that indeed lie in the query half-plane While recursing down only in triangles that are not completely contained in either side of the of query half-plane.
Select In Half-Plane Algorithm (cont. in more detail) 56
Select In Half-Plane Algorithm (cont. in more detail) 57
58 Query time Analysis The number of classes Max. number of classes recursed, by the crossing number
The space required by the tree
Pre-process time