Function petgraph::algo::dijkstra[][src]

pub fn dijkstra<G, F, K>(
    graph: G,
    start: G::NodeId,
    goal: Option<G::NodeId>,
    edge_cost: F
) -> HashMap<G::NodeId, K> where
    G: IntoEdges + Visitable,
    G::NodeId: Eq + Hash,
    F: FnMut(G::EdgeRef) -> K,
    K: Measure + Copy

[Generic] Dijkstra's shortest path algorithm.

Compute the length of the shortest path from start to every reachable node.

The graph should be Visitable and implement IntoEdges. The function edge_cost should return the cost for a particular edge, which is used to compute path costs. Edge costs must be non-negative.

If goal is not None, then the algorithm terminates once the goal node's cost is calculated.

Returns a HashMap that maps NodeId to path cost.