Slug: graph-dijkstra-01 · Paired reading: Chapter 21
Prompt
Weighted directed graph as Vec<Vec<(usize, u64)>> (neighbor, weight).
fn dijkstra(g: &[Vec<(usize, u64)>], src: usize) -> Vec<u64> — distances
(u64::MAX if unreachable). BinaryHeap of Reverse<(dist, node)>; skip
stale heap entries.
Contract
- Distances from
src; unreachable nodes →u64::MAX - Empty outgoing adjacency is allowed;
srcdistance is0 - Stale binary-heap entries must be skipped (shorter path wins)