astar-0.3.0.0: General A* search algorithm.

Data.Graph.AStar

Synopsis

Documentation

Arguments

 :: (Hashable a, Ord a, Ord c, Num c) => (a -> HashSet a) The graph we are searching through, given as a function from vertices to their neighbours. -> (a -> a -> c) Distance function between neighbouring vertices of the graph. This will never be applied to vertices that are not neighbours, so may be undefined on pairs that are not neighbours in the graph. -> (a -> c) Heuristic distance to the (nearest) goal. This should never overestimate the distance, or else the path found may not be minimal. -> (a -> Bool) The goal, specified as a boolean predicate on vertices. -> a The vertex to start searching from. -> Maybe [a] An optimal path, if any path exists. This excludes the starting vertex.

This function computes an optimal (minimal distance) path through a graph in a best-first fashion, starting from a given starting point.

Arguments

 :: (Monad m, Hashable a, Ord a, Ord c, Num c) => (a -> m (HashSet a)) The graph we are searching through, given as a function from vertices to their neighbours. -> (a -> a -> m c) Distance function between neighbouring vertices of the graph. This will never be applied to vertices that are not neighbours, so may be undefined on pairs that are not neighbours in the graph. -> (a -> m c) Heuristic distance to the (nearest) goal. This should never overestimate the distance, or else the path found may not be minimal. -> (a -> m Bool) The goal, specified as a boolean predicate on vertices. -> m a The vertex to start searching from. -> m (Maybe [a]) An optimal path, if any path exists. This excludes the starting vertex.

This function computes an optimal (minimal distance) path through a graph in a best-first fashion, starting from a given starting point.