We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fe5efe8 commit 54a6453Copy full SHA for 54a6453
1 file changed
src/directed/dijkstra.rs
@@ -214,11 +214,17 @@ where
214
let mut target_reached = None;
215
while let Some(SmallestHolder { cost, index }) = to_see.pop() {
216
let successors = {
217
- let (node, _) = parents.get_index(index).unwrap();
+ let (node, &(_, c)) = parents.get_index(index).unwrap();
218
if stop(node) {
219
target_reached = Some(index);
220
break;
221
}
222
+ // We may have inserted a node several time into the binary heap if we found
223
+ // a better way to access it. Ensure that we are currently dealing with the
224
+ // best path and discard the others.
225
+ if cost > c {
226
+ continue;
227
+ }
228
successors(node)
229
};
230
for (successor, move_cost) in successors {
0 commit comments