Skip to main content

dijkstra

Function dijkstra 

Source
pub fn dijkstra(
    graph: &[Vec<(usize, u64)>],
    source: usize,
) -> HashMap<usize, u64>
Expand description

Compute shortest distances from source to every reachable vertex.

graph[u] is the list of edges leaving u: pairs (v, w) meaning there is an edge to v with weight w. Returns a map from vertex id to minimum distance. Unreachable vertices are absent.

ยงPanics

Panics if source >= graph.len().