Slideshow:
|
|
|
Insert Algorithm: (to insert an new object (mbb, ObjID) into a leaf node of the R-tree)
/* ================================================ Insert( (mbb,ObjID), n) (mbb,ObjID) = object with given mbb n = current node of operation ================================================= */ Insert( (mbb, ObjID), n ) { // n = current node of the search in the R-tree if ( n == internal node ) { for ( each entry ( BB, childptr ) in node n ) do { /* ====================================================== Insert the object in subtree of the first BB that contains the mbb of the inserted object ====================================================== */ if ( mbb of inserted object ⊆ BB ) { Situation: /* ---------------------------------------------- Insert the object in this subtree !!! ---------------------------------------------- */ Insert( (mbb,ObjID), childptr); // Insert !! /* ---------------------------------------------- The recursion WILL have inserted the object ! ---------------------------------------------- */ return; // Terminates the for-loop !!! } } /* ********************************************************* We can ONLY reach here when EVERY BB (Bounding Box) in the node n does not contain the object !!! We enlarge one of the BB so it can index the new object ********************************************************* */ Find a BB in n such that: Enlarging BB to contain the new object will add the least amount of area to the bounding box BB Update this BB in n to the Enlarged BB; (Note: We do not need to update the BB in the parent node because THAT BB contains the insert object) /* ====================================================== Now the enlarged BB contains the object !!! ====================================================== */ Insert( (mbb,ObjID), childptr); // Insert in subtree !! return; // Done } else // We reached a leaf node { /* ================================================= We found the leaf node to hold the object !!! ================================================= */ if ( leaf node has space to hold object ) { insert (mbb, ObjID) in the leaf node; } else { Split the objects in the leaf node into set1 and set2; // Set1 and set2 are 2 set of objects // How to split the objects is a new subproblem... Find the bounding box BB1 for set1 of the objects; Find the bounding box BB2 for set2 of the objects; // You will have 2 bounding boxes Replace the parent's (BB, ptr) by (BB1, set1) and (BB2, set2); (This step can cause the parent node to overflow !!! We will need to split the parent node into 2 internal nodes You will use a Insert procedure into an internal node - just like the B-tree algorithm !!) } } } |
|
Steps of the Insert Algorithm:
|
|
Steps of the Insert Algorithm:
|
|
Steps of the Insert Algorithm:
|
|
|
|
|
Problem description:
|
Example:
|
|