/** * Check whether another node is near by the their identifier * * @param Node $otherNode * @return bool */ public function isNear(Node $otherNode) { $otherIdentifier = $otherNode->getIdentifier(); if ($otherIdentifier->getSize() != $this->identifier->getSize()) { return false; } $differences = 0; for ($i = 0; $i < $this->dimensions; $i++) { if ($otherIdentifier[$i] != $this->identifier[$i]) { $differences++; } if ($differences > 1) { return false; } } return true; }