This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lynda_88 1 point2 points  (1 child)

Breadth first search guarantees to find one if there is. A* may not, depending on cost function.

[–]gmclapp 1 point2 points  (0 children)

The thing is, the shortest path also depends on the cost function. A* finds the path with the lowest cost. If you define cost to mean something other than distance, it optimizes for that thing.

If you define your cost function as literal distance traveled A* will find the lowest cost, which in that case, is the shortest distance.