I would like to obtain a "slick" implementation of A*-search algorithm on Graph objects, using the built-in BreadthFirstScan (if that is possible at all). I noticed that BreadthFirstScan is static in the sense that once a graph g is given to,

BreadthFirstScan[g, StartNode, {"DiscoverVertex -> func}]

'func' cannot alter g as need be and hence cannot run the course of the A*-search algorithm.

I know of one solution to A* algorithm on Mathematica.se, but it seems too verbose. Is it possible to use BreadthFirstScan? My rough guess is that it is not, but I want to confirm. To summarize my question is this: "Is there a way to make BreadthFirstScan alter its path?" I know that Throw can be used inside the execution of BreadthFirstScan, but it only jumps out of an "event" (e.g., "DiscoverVertex"), not alter the path of traversal for the graph.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.