fix Yen K-shortest when there are not enough shortest paths https://github.com/cozodb/cozo/issues/166

main
Ziyang Hu 1 year ago
parent d3c1cde97a
commit 75b012bab8

@ -202,7 +202,10 @@ fn k_shortest_path_yen(
}
candidates.sort_by(|(a_cost, _), (b_cost, _)| b_cost.total_cmp(a_cost));
let shortest = candidates.pop().unwrap();
let shortest_dist = shortest.0;
if shortest_dist.is_finite() {
k_shortest.push(shortest);
}
}
Ok(k_shortest)
}

Loading…
Cancel
Save