Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bmichotte committed Apr 30, 2019
1 parent 6be5709 commit be77e1c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Dijkstra.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ protected function run(Point $parent): self
$this->calculateWeight($parent, $child);
}

return $this->findNextParent();
}

protected function findNextParent(): self
{
// search for the next parent (smallest weight)
// we have to find the smallest weight for a node we didn't passed by atm
$smallest = INF;
Expand All @@ -73,7 +78,8 @@ protected function run(Point $parent): self
$nextParent = $weight['position'];
}
}
if (! is_null($nextParent)) {

if ($nextParent !== null) {
return $this->run($nextParent);
}

Expand Down

0 comments on commit be77e1c

Please sign in to comment.