Skip to content

Commit

Permalink
fix(astar): Ord impl on SmallestCostHolder was half backward
Browse files Browse the repository at this point in the history
  • Loading branch information
rjooske committed Aug 14, 2024
1 parent 3c3f05f commit dc8a3e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/directed/astar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl<K: Ord> PartialOrd for SmallestCostHolder<K> {
impl<K: Ord> Ord for SmallestCostHolder<K> {
fn cmp(&self, other: &Self) -> Ordering {
match other.estimated_cost.cmp(&self.estimated_cost) {
Ordering::Equal => self.cost.cmp(&other.cost),
Ordering::Equal => other.cost.cmp(&self.cost),
s => s,
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pathfinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ mod ex2 {
.expect("path not found");
assert_eq!(cost, 8);
assert!(path.iter().all(|&(nx, ny)| OPEN[ny][nx]));
assert_eq!(counter, 11);
assert_eq!(counter, 14);
}

#[test]
Expand Down

0 comments on commit dc8a3e7

Please sign in to comment.