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

pub fn dijkstra_partial<N, C, FN, IN, FS>(
    start: &N,
    successors: FN,
    stop: FS
) -> (HashMap<N, (N, C)>, Option<N>) where
    N: Eq + Hash + Clone,
    C: Zero + Ord + Copy,
    FN: FnMut(&N) -> IN,
    IN: IntoIterator<Item = (N, C)>,
    FS: FnMut(&N) -> bool

Determine some reachable nodes from a starting point as well as the minimum cost to reach them and a possible optimal parent node using the Dijkstra search algorithm.

  • start is the starting node.
  • successors returns a list of successors for a given node, along with the cost for moving from the node to the successor.
  • stop is a function which is called every time a node is examined (including start). A true return value will stop the algorithm.

The result is a map where every node examined before the algorithm stopped (not including start) is associated with an optimal parent node and a cost, as well as the node which caused the algorithm to stop if any.

The build_path function can be used to build a full path from the starting point to one of the reachable targets.