Example #1
0
 /**
  * So called "re-plant" operation: change node parent
  *
  * @param \Includes\DataStructure\Graph $oldParent Replant from
  * @param \Includes\DataStructure\Graph $newParent Replant to
  *
  * @return void
  */
 public function replant(\Includes\DataStructure\Graph $oldParent, \Includes\DataStructure\Graph $newParent)
 {
     $oldParent->removeChild($this);
     $newParent->addChild($this);
 }
Example #2
0
 /**
  * Remove child node
  *
  * @param \Includes\DataStructure\Graph $node Node to remove
  *
  * @return void
  */
 public function removeChild(\Includes\DataStructure\Graph $node)
 {
     foreach ($this->getChildren() as $index => $child) {
         if ($node->getKey() === $child->getKey()) {
             $node->setParent(null);
         }
     }
     parent::removeChild($node);
 }
Example #3
0
 /**
  * So called "re-plant" operation: change node parent
  *
  * @param self $oldParent Replant from
  * @param self $newParent Replant to
  *
  * @return void
  */
 public function replant(self $oldParent, self $newParent)
 {
     $oldParent->removeChild($this);
     $newParent->addChild($this);
 }