The algorithm of A star search with a specified goal is pretty straightforward. However, what if there are multiple goals in a graph. For instance; you may want to find a sh
You are describing conditions on path and not conditions on goal. A*, like all search algorithms - is finding a path to a goal [could be in a set, of goal, no problems with that].
Your problem [for the general case] is at least as hard as the Traveling Salesman Problem, and thus this problem is NP-Hard.
The reduction is simple: Given an instance of TSP - find the shortest path from a certain v
to v
such that the path is going through all vertices [constraint]. You can do it by simply marking each vertex with a different mark.
Note however, that A*
algorithm has no problem to find shortest path to a vertex in a set of goal vertices. Remember that A* is based on Dijkstra's Algorithm, which is finding shortest path to all vertices from a single source.