Skip to content

Commit

Permalink
Merge pull request #5 from PapsOu/patch-2
Browse files Browse the repository at this point in the history
Allow override of static method Dijkstra::distance
  • Loading branch information
bmichotte authored Jul 18, 2019
2 parents f5df426 + 93e142b commit 12fd031
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
}
],
"require": {
"php": "^7.1"
"php": "^7.1",
"ext-bcmath": "*"
},
"require-dev": {
"ext-gd": "*",
Expand Down
4 changes: 2 additions & 2 deletions src/Dijkstra.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ protected function calculateWeight(Point $parent, Point $child): void
* ENDIF
*/
if (! $this->weights[$child->ref]['passed']
&& ($this->weights[$parent->ref]['weight'] + self::distance($parent, $child) < $this->weights[$child->ref]['weight']
&& ($this->weights[$parent->ref]['weight'] + static::distance($parent, $child) < $this->weights[$child->ref]['weight']
|| $this->weights[$child->ref]['weight'] === -1)) {
$this->weights[$child->ref]['weight'] = $this->weights[$parent->ref]['weight'] + self::distance($parent, $child);
$this->weights[$child->ref]['weight'] = $this->weights[$parent->ref]['weight'] + static::distance($parent, $child);
$this->predecessors[$child->ref]['previous'] = $parent;
}
}
Expand Down

0 comments on commit 12fd031

Please sign in to comment.