2

I am trying to implement an R-tree in scala following the guidelines from the original paper about the R-tree structure. In the deletion algorithm section is stated:

Reinsert all entries of nodes in set Q. Entries from eliminated leaf nodes are reinserted in tree leaves as described in Insert, but entries from higher level nodes must be placed higher in the tree, so that leaves of their depedent subtrees will be on the same level as leaves of the main tree.

I can't wrap my head around the last part. What is meant by higher level nodes must be placed higher in the tree? How is that implemented? My idea was that I remove nodes that underflow add them to the set Q (their entries) and in the end I reinsert their entries using Insert. Is this incorrect or partially correct that requires something extra? If you can explain using examples as well that would be great.

JimS
  • 349
  • 1
  • 4
  • 19

2 Answers2

0

Nodes must be reinserted in the correct height, or the tree will become invalid. Remember that all leaves must be at the same level.

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
  • Why do I need to place the nodes again? If I take the entries of the eliminated nodes and reinsert them doesn't that work? Or do I traverse through the root comparing with the node's mbr and re-attach the subtree? – JimS Oct 13 '19 at 22:45
  • You want to reattach entire subtrees. – Has QUIT--Anony-Mousse Oct 14 '19 at 05:52
0

Inserting and removing values in R-Tree is a quite expensive operation when you need to keep it optimally balanced for fast window or nearest requests, especially in a multi-thread environment.

A more efficient approach is using one writer (actor or thread) which gathers updates in batches, packs a new R-Tree instance and publishes it in some volatile variable for reading.

Here is a comparison of some R-Tree implementations that can be used in such a way from Scala.

Andriy Plokhotnyuk
  • 7,883
  • 2
  • 44
  • 68
  • Yes, I know of this approach but I am trying to implement the algorithm as stated in the paper. Can you explain how the node reattachment works? – JimS Oct 19 '19 at 21:19