R Trees - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

R Trees

Description:

Multi-dimensional spaces not well represented by point locations ... let F be the entry in N whose rectangle needs least enlargement to include E.I ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 21
Provided by: laksh8
Category:
Tags: trees

less

Transcript and Presenter's Notes

Title: R Trees


1
R Trees
  • A Dynamic Index Structure for Spatial
    Representation

2
Why R Trees?
  • Multi-dimensional spaces not well represented by
    point locations
  • Need to be able to perform range searches
  • One dimensional indexes not suitable for
    multi-dimensional spaces
  • Ex Find all the counties within 20 mi radius of
    Georgia Tech

3
Main Concepts
  • Height balanced tree similar to a B-tree
  • Index records in leaf nodes point to data objects
  • Index is dynamic and no periodic reorganization
    is require
  • Index records are of the form ( _at_ leaf nodes)
  • (I, tuple-identifier)
  • where
  • I gt n dimensional bounding rectangle i.e.
  • I (I0,I1,,In) where n no of dimensions and
    Ii a, b (a closed bounded rectangle)

4
More Concepts
  • Non leaf nodes are of the form
  • (I, child-pointer)
  • where
  • child-pointer is the address of a lower node
    and I is the smallest rectangle covering all the
    rectangles in the lower nodes entries
  • M maximum number of entries in one node

5
More Concepts
  • m parameter specifying the minimum no of
    entries in a node.
  • m can be tuned at run time and is lt M/2
  • R tree containing N index records has at most a
    height logm N -1
  • Worst case space utilization m/M
  • Maximum no of nodes N/m N/m2 1

6
Searching
  • Denote the rectangle part of a node E by E.I and
    the child-pointer part by E.p
  • Algorithm Search Given an R Tree with root node
    T find all index records whose rectangles overlap
    a search rectangle S
  • Step 1) Search subtrees. If T is not a leaf,
    check each entry to determine if E.I overlaps S.
    For all overlapping entries invoke Search on the
    tree whose root is E.p
  • Step 2) Search leaf node. If T is a leaf, check
    all entries E to determine whether E.I overlaps
    S. If so, E is a qualifying records. Return E.

7
Insertion into R-Tree
  • Similar to B-Tree insertion
  • New index records added to leaves
  • Overflowing nodes are split
  • Splits propagate up the tree

8
Algorithm Insert - Details
  • Invoke ChooseLeaf to select a leaf node L to
    place E
  • If L has room for another entry install E, else
    invoke SplitNode on L, obtaining L and LL
  • Invoke AdjustTree on L (and LL if a split was
    performed)
  • If root is split, create new root with two
    children (those obtained by splitting the old
    root)

9
Algorithm ChooseLeaf
  • Set N to be the root
  • If N is leaf, return N
  • If N is not leaf, let F be the entry in N whose
    rectangle needs least enlargement to include E.I
  • Set N to be the child node pointed to by F.P and
    repeat from Step 2

10
Algorithm AdjustTree
  • Set N L, if L was split set NN LL
  • If N is Root, STOP
  • Let P be Ns parent and let EN be Ns entry in P.
    Adjust EN.I so that it tightly encloses all
    entries in N
  • If NN exists, create a new entry ENN, with ENN.p
    pointing to NN and ENN.I enclosing all rectangles
    in NN. Add ENN to P if there is room. Otherwise
    invoke SplitNode to produce PP.
  • Move up the next level, repeat process

11
Node Splitting
  • Full node to be split when new entry needs to
    be added
  • Must ensure that on any subsequent searches, with
    high probability only one node needs to be
    explored
  • Total area of two rectangles to be minimized
  • Exhaustive Search Exponential Complexity

12
Quadratic Cost Algorithm
  • Use PickSeeds to choose two entries to be first
    elements of the two groups.
  • Repeat STEP 3 until all entries have been
    assigned to one of the groups
  • Invoke algorithm PickNext to choose next entry to
    assign. Add it to the group whose covering
    rectangle needs to be expanded the least.

13
Algorithm PickSeeds
  • For each pair of entries E1 and E2, let J be the
    rectangle including E1.I and E2.I. Calculate d
    area(J) area(E1.I) area(E2.I)
  • Choose the pair with largest d value

14
Algorithm PickNext
  • For each entry E not yet in any group, calculate
    d1 the area increase required in the covering
    rectangle of Group 1 to include E.1. Calculate d2
    similarly for Group 2
  • Choose any entry with maximum difference between
    d1 and d2

15
Algorithm LinearPickSeeds
  • Along each dimension, find the entry whose
    rectangle has the highest low side, and the one
    with highest low side. Record the separation
    between them
  • Normalize the separations by dividing by the
    width of the entire set along corresponding
    dimension
  • Choose the pair with greatest normalized
    separation along any dimension

16
Algorithm Delete
  • Invoke FindLeaf to locate leaf node L containing
    E.
  • Remove E from L
  • Invoke CondenseTree on L
  • If root node has only one child, make the child
    the new root

17
Algorithm FindLeaf
  • Set T to be the root of the tree
  • If T is not leaf, check each entry F in T to
    determine if F.I overlaps E.I. For each entry,
    invoke FindLeaf on the tree pointed to by F.P
  • If T is a leaf, check each entry to see if it
    matches E. If E is found return T

18
Algorithm CondenseTree
  • Set N L. Set Q, the set of eliminated nodes as
    empty set
  • If N is the root, go to STEP 6, else, let P be
    the parent of N, and let EN be Ns entry in P
  • If N has fewer than m entries, delete EN from P
    and add N to Q

19
Algorithm CondenseTree (contd..)
  • If N not eliminated, adjust EN.I to tightly
    contain all entries in N
  • Set N P and repeat from STEP 2
  • Reinsert all entries in Q. Entries from
    eliminated leaf nodes are inserted as in
    algorithm Insert. Entries from higher-level nodes
    are to be inserted higher in the tree.

20
Conclusions
  • Paper presents R-Tree a data structure to
    handle spatial data efficiently
  • Includes algorithms for searching, inserting and
    deleting spatial data nodes
  • Experimental results indicate reasonable
    performance
Write a Comment
User Comments (0)
About PowerShow.com