This article compares their path-finding processes in the form of a diagram to give you a clear and intuitive impression of them.
We compared the following five algorithms:
1. A * (using the Manhattan distance)
2. A * (using Euclidean distance)
3. A * (using the distance from cherbihov)
4. Dijkstra
5. Bi-Directional Breadth-First-Search (bidirectional Breadth-First Search)
For exampleGreenThe color square indicates the starting point,RedThe color square represents the target point,PurpleColor blocks represent obstacles, and white blocks represent accessible paths.
Below, we can place the starting point green blocks and the target point red blocks at will, and then draw some obstacles between them,
Finally, run the program and use the above five algorithms to obtainTheir respective paths, their respective scopes covered in the process, and their respective workflowsAnd you can see their efficiency.
A * Performance Comparison of Dijkstra and BFS algorithms:
OK. Three statuses of any green block and red block are displayed:
I. Starting Point green block, which is in the same horizontal line as the target point red block:
Their respective Search paths are:
1. A * (using the Manhattan distance)
2. A * (using Euclidean distance)
3. A * (using the distance from cherbihov)
4. Dijkstra algorithm. // it is obvious that Dijkstra search efficiency is much lower than A * algorithm. (You can easily see the path and coverage of the red block of the target point. The comparison below is based on the same principle.View paths, view coverage, and evaluate the efficiency of an algorithm).
5. Bi-Directional Breadth-First-Search (bidirectional Breadth-First Search)
2. The starting point is green, and the target point is red on a diagonal line:
Their respective Search paths are:
1. A * (using the Manhattan distance)
2. A * (using Euclidean distance)
3. A * (using the distance from cherbihov)
4. Dijkstra algorithm. // Compared with the preceding A * algorithm, the algorithm has A large coverage and low search efficiency.
5. Bi-Directional Breadth-First-Search (bidirectional Breadth-First Search)
3. Starting Point green block, the red block of the target point is blocked by multiple obstacles:
The respective Search Path is (Similarly, from green block to red block):
1. A * (using the Manhattan distance)
2. A * (using Euclidean distance )..
3. A * (using the distance from cherbihov)
4. Dijkstra ....
5. Bi-Directional Breadth-First-Search (bidirectional Breadth-First Search)// The coverage is as large as the Dijkstra algorithm, and the efficiency is low.
A * efficiency of search algorithms
As shown above, do I have A general impression on the performance of A *, Dijkstra, and bidirectional BFS algorithms? From the above demonstration, we can see that in the shortest path search efficiency, there are generally A *> Dijkstra, two-way BFS, where Dijkstra, two-way BFS in the end which algorithm is better, depending on the specific situation.
From the above, we can also see that A * search algorithm is indeed A more efficient pathfinding algorithm.
A * process with the most core AlgorithmsWhen you select the next search pointPoint found but not searchedMedium (may be different layers or not on the same branch), select the node with the minimum F value for expansion