Need an idea for A star search algorithm with multiple goals

前端 未结 3 907
孤街浪徒
孤街浪徒 2020-12-19 19:56

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

3条回答
  •  时光取名叫无心
    2020-12-19 20:15

    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.

提交回复
热议问题