When comparing Breadth-first search vs A* Algorithm, the Slant community recommends A* Algorithm for most people. In the question“What are the best 2D pathfinding algorithms?” A* Algorithm is ranked 1st while Breadth-first search is ranked 3rd. The most important reason people chose A* Algorithm is:
A* is complete, which means that it will always find a solution if it exists.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Complete
BFS is complete, which means that it will always find a solution if it exists.
Pro Optimal for finding the shortest path in a graph
BFS is very useful when you want to find the shortest and most optimal path by traversing as few edges as possible.
Pro Complete
A* is complete, which means that it will always find a solution if it exists.
Pro Can be morphed into other algorithms
A* can be morphed into another path-finding algorithm by simply playing with the heuristics it uses and how it evaluates each node. This can be done to simulate Dijkstra, Best First Search, Breadth First Search and Depth First Search.
Pro Heuristic
A* expands on a node only if it seems promising. It's only focus is to reach the goal node as quickly as possible from the current node, not to try and reach every other node.
Cons
Con Requires a large amount of memory
When traversing one tree level, you need a way to know which nodes to traverse once you get to the next one. The way this is done is by storing the pointers to a level's child nodes while searching it. The pointers are stored in a FIFO way, this means that BFS needs a relatively large amount of memory in order to store the pointers. The amount of course depends on the complexity of the graph tree and the amount of nodes and/or levels.
Con Not useful if you have many target nodes
If you have many target nodes and you don't know which one is closest to the main one, A* is not very optimal. This is because it needs to be run several times (once per target node) in order to get to all of them.