[][src]Function pathfinding::directed::dijkstra::build_path

pub fn build_path<N, C>(target: &N, parents: &HashMap<N, (N, C)>) -> Vec<N> where
    N: Eq + Hash + Clone

Build a path leading to a target according to a parents map, which must contain no loop. This function can be used after dijkstra_all or dijkstra_partial to build a path from a starting point to a reachable target.

  • target is reachable target.
  • parents is a map containing an optimal parent (and an associated cost which is ignored here) for every reachable node.

This function returns a vector with a path from the farthest parent up to target, including target itself.

Panics

If the parents map contains a loop, this function will attempt to build a path of infinite length and panic when memory is exhausted.