The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Range Search rectangles, because the inside/outside test reduces to verifying whether each coordinate lies within a prescribed range. The figure above illustrates such an orthogonal range query. If you are querying against a nonconvex polygon, it will pay to partition your polygon into convex pieces or (even better) triangles and then query the point set against each one of the pieces. This is because testing whether a point is inside a convex polygon can be done more quickly and easily than for arbitrary polygons. Algorithms for such convex decompositions are discussed in Section . ● How many dimensions? - The best general-purpose approach to range queries builds a kd-tree on the point set, as discussed in Section . To perform a query, a depth-first traversal of the kd-tree is performed, with each tree node expanded only if the associated rectangle intersects the query region. For sufficiently large or misaligned query regions, the entire tree might have to be traversed, but in general; kd-trees lead to an efficient solution. Although algorithms with efficient worst-case performance are known in two dimensions, kd-trees are likely to work even better in the plane. In higher-dimensions, kd-trees provide the only viable solution to the problem. ● Can I just count the number of points in a region, or do I have to identify them? - For many applications it suffices to count the number of points in a region instead of returning them. Harkening back to the introductory example, we may want to know whether there are more thin/poor people or rich/fat ones. The need to find the densest or emptiest region in space often naturally arises, and the problem can be solved by counting range queries. A data structure for efficiently answering such aggregate range queries can be based on the dominance ordering of the point set. A point x is said to dominate point y if y lies both below and to the left of x. Let DOM(p) be a function that counts the number of points in S that are dominated by p. The number of points m in the orthogonal rectangle defined by and is given by The second additive term corrects for the points for the lower left-hand corner that have been subtracted away twice. To answer arbitrary dominance queries efficiently, partition the space into rectangles by drawing a horizontal and vertical line through each of the n points. The set of points dominated is identical for each point in each rectangle, so the dominance count of the lower left-hand corner of each rectangle can precomputed, stored, and reported for any query point within it. Queries reduce to binary search and thus take time. Unfortunately, this data structure takes quadratic space. However, the same idea can be adapted to kd-trees to create a more space-efficient search structure. Implementations: LEDA (see Section ) provides excellent support for maintaining planar file:///E|/BOOK/BOOK4/NODE189.HTM (2 of 3) [19/1/2003 1:31:45]
Range Search subdivisions in C++. In particular, it supports orthogonal range queries in time, where n is the complexity of the subdivision and k is the number of points in the rectangular region. Ranger is a tool for visualizing and experimenting with nearest-neighbor and orthogonal-range queries in high-dimensional data sets, using multidimensional search trees. Four different search data structures are supported by Ranger: naive kd-trees, median kd-trees, nonorthogonal kd-trees, and the vantage point tree. For each of these, Ranger supports queries in up to 25 dimensions under any Minkowski metric. It is available in the algorithm repository. A bare bones implementation in C of orthogonal range search using kd-trees appears in [GBY91]. Sedgewick [Sed92] provides code fragments of the grid method for orthogonal range search in C++. See Section for details on both of them. Notes: Good expositions on data structures with worst-case performance for orthogonal-range searching [Wil85] include [PS85]. An exposition on kd-trees for orthogonal range queries in two dimensions appears in [PS85]. Their worst-case performance can be very bad; [LW77] describes an instance in two dimensions requiring time to report that a rectangle is empty. The problem becomes considerably more difficult for nonorthogonal range queries, where the query region is not an axis-aligned rectangle. For half-plane intersection queries, time and linear space suffice [CGL85]; for range searching with simplex query regions (such as a triangle in the plane), lower bounds preclude efficient worst-case data structures. See [Yao90] for a discussion. Related Problems: Kd-trees (see page ), point location (see page ), Next: Point Location Up: Computational Geometry Previous: Nearest Neighbor Search Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK4/NODE189.HTM (3 of 3) [19/1/2003 1:31:45]
- Page 527 and 528: Traveling Salesman Problem Size is
- Page 529 and 530: Hamiltonian Cycle Eulerian cycle, p
- Page 531 and 532: Graph Partition Next: Vertex Colori
- Page 533 and 534: Graph Partition annealing, is almos
- Page 535 and 536: Vertex Coloring Several special cas
- Page 537 and 538: Vertex Coloring Notes: An excellent
- Page 539 and 540: Edge Coloring The minimum number of
- Page 541 and 542: Graph Isomorphism Next: Steiner Tre
- Page 543 and 544: Graph Isomorphism vertices into equ
- Page 545 and 546: Steiner Tree Next: Feedback Edge/Ve
- Page 547 and 548: Steiner Tree The worst case for a m
- Page 549 and 550: Feedback Edge/Vertex Set Next: Comp
- Page 551 and 552: Feedback Edge/Vertex Set An interes
- Page 553 and 554: Computational Geometry complete bib
- Page 555 and 556: Robust Geometric Primitives Next: C
- Page 557 and 558: Robust Geometric Primitives ● Are
- Page 559 and 560: Robust Geometric Primitives Related
- Page 561 and 562: Convex Hull ● How many dimensions
- Page 563 and 564: Convex Hull http://www.cs.att.com/n
- Page 565 and 566: Triangulation Next: Voronoi Diagram
- Page 567 and 568: Triangulation GEOMPACK is a suite o
- Page 569 and 570: Voronoi Diagrams Next: Nearest Neig
- Page 571 and 572: Voronoi Diagrams McDonald's, the ti
- Page 573 and 574: Nearest Neighbor Search Next: Range
- Page 575 and 576: Nearest Neighbor Search Implementat
- Page 577: Range Search Next: Point Location U
- Page 581 and 582: Point Location the n edges for inte
- Page 583 and 584: Point Location More recently, there
- Page 585 and 586: Intersection Detection ● Do you w
- Page 587 and 588: Intersection Detection Implementati
- Page 589 and 590: Bin Packing Next: Medial-Axis Trans
- Page 591 and 592: Bin Packing approach for general sh
- Page 593 and 594: Medial-Axis Transformation Next: Po
- Page 595 and 596: Medial-Axis Transformation Implemen
- Page 597 and 598: Polygon Partitioning number of piec
- Page 599 and 600: Simplifying Polygons Next: Shape Si
- Page 601 and 602: Simplifying Polygons vertices and o
- Page 603 and 604: Shape Similarity Next: Motion Plann
- Page 605 and 606: Shape Similarity or how close it is
- Page 607 and 608: Motion Planning There is a wide ran
- Page 609 and 610: Motion Planning often arise in the
- Page 611 and 612: Maintaining Line Arrangements Think
- Page 613 and 614: Maintaining Line Arrangements Next:
- Page 615 and 616: Minkowski Sum where x+y is the vect
- Page 617 and 618: Set and String Problems Next: Set C
- Page 619 and 620: Set Cover Next: Set Packing Up: Set
- Page 621 and 622: Set Cover Figure: Hitting set is du
- Page 623 and 624: Set Packing Next: String Matching U
- Page 625 and 626: Set Packing Notes: An excellent exp
- Page 627 and 628: String Matching shouldn't try. Furt
Range Search<br />
rectangles, because the inside/outside test reduces to verifying whether each coordinate lies<br />
within a prescribed range. <strong>The</strong> figure above illustrates such an orthogonal range query.<br />
If you are querying against a nonconvex polygon, it will pay to partition your polygon into convex<br />
pieces or (even better) triangles and then query the point set against each one of the pieces. This is<br />
because testing whether a point is inside a convex polygon can be done more quickly and easily<br />
than for arbitrary polygons. <strong>Algorithm</strong>s for such convex decompositions are discussed in Section<br />
.<br />
● How many dimensions? - <strong>The</strong> best general-purpose approach to range queries builds a kd-tree on<br />
the point set, as discussed in Section . To perform a query, a depth-first traversal of the kd-tree<br />
is performed, with each tree node expanded only if the associated rectangle intersects the query<br />
region. For sufficiently large or misaligned query regions, the entire tree might have to be<br />
traversed, but in general; kd-trees lead to an efficient solution. Although algorithms with efficient<br />
worst-case performance are known in two dimensions, kd-trees are likely to work even better in<br />
the plane. In higher-dimensions, kd-trees provide the only viable solution to the problem.<br />
● Can I just count the number of points in a region, or do I have to identify them? - For many<br />
applications it suffices to count the number of points in a region instead of returning them.<br />
Harkening back to the introductory example, we may want to know whether there are more<br />
thin/poor people or rich/fat ones. <strong>The</strong> need to find the densest or emptiest region in space often<br />
naturally arises, and the problem can be solved by counting range queries.<br />
A data structure for efficiently answering such aggregate range queries can be based on the<br />
dominance ordering of the point set. A point x is said to dominate point y if y lies both below and<br />
to the left of x. Let DOM(p) be a function that counts the number of points in S that are dominated<br />
by p. <strong>The</strong> number of points m in the orthogonal rectangle defined by and<br />
is given by<br />
<strong>The</strong> second additive term corrects for the points for the lower left-hand corner that have been<br />
subtracted away twice.<br />
To answer arbitrary dominance queries efficiently, partition the space into rectangles by<br />
drawing a horizontal and vertical line through each of the n points. <strong>The</strong> set of points dominated is<br />
identical for each point in each rectangle, so the dominance count of the lower left-hand corner of<br />
each rectangle can precomputed, stored, and reported for any query point within it. Queries reduce<br />
to binary search and thus take time. Unfortunately, this data structure takes quadratic<br />
space. However, the same idea can be adapted to kd-trees to create a more space-efficient search<br />
structure.<br />
Implementations: LEDA (see Section ) provides excellent support for maintaining planar<br />
file:///E|/BOOK/BOOK4/NODE189.HTM (2 of 3) [19/1/2003 1:31:45]