コード例 #1
0
 def updateoninsertion(self, node):
     """
     Creates a new cell for the new node and updates the cells of its neighbors. 
     The new inserted node does not split a jump. The nearby uninserted points are 
     in the cells of nearby nodes from one level up to one level down.
     
     Parameters:
     ----------
     node : Node
         The new inserted node.
     """
     self.addnode(node)
     for point in self.rnn_out(rel(par(node)) | ch(rel(par(node))) | ch(rel(node))):
         self.trytochangernn(point, node)
コード例 #2
0
 def updateonsplit(self, node):
     """
     Creates a new cell for the new inserted node, which splits a jump, from the cell of its parent.
     
     Parameters:
     ----------
     node : Node
         The new inserted node.
     """
     self.addnode(node)
     # The cells of the leaves or the nodes in level -\infty are always empty
     if node.level != float('-inf'):
         for point in self.rnn(par(node)):
             self.trytochangernn(point, node)
コード例 #3
0
 def update_rel(self, node, closest):
     """
     Updates the relative list of a given node.
     
     Parameters:
     ----------
     node : Node
         The node that its relatives should be updated.
     closest : Node
         The node closest to `node` at the same level.
     """
     for other in ch(rel(par(closest))):
         if self.isrel(node, other):
             if other.level < node.level:
                 other = self.splitabove(other, node.level)
             node.addrel(other)
コード例 #4
0
 def update_par(self, node, closest):
     """
     Updates the parent of a given node.
     
     Parameters:
     ----------
     node : Node
         The node that its parent should be updated.
     closest : Node
         The node closest to `node` at the same level.
     """
     newpar = nearest(node, rel(par(closest)))
     # There may be a node in rel(par(@closest)) such that
     # its distance to `node` is the same as the distance of `node` to `closest.par`.
     # In this case, the right parent should be the parent of `closest`,
     # otherwise we may need to delete `closest` from the tree.
     if dist(node, newpar) == dist(node, closest.par):
         newpar = closest.par
     if newpar.getchild().level < node.level:
         self.splitbelow(newpar, node.level)
         if self.isrel(node, newpar): node.addrel(newpar.getchild())
     node.setpar(newpar)