So far, what you’ve created is a modified Dijkstra’s algorithm that has a target and returns the path to that target.
To make this algorithm truly
a star A*, you’ll need to add a heuristic that estimates the distance from a given vertex to the target.
By doing this, the algorithm is able to efficiently and accurately predict whether or not it is heading in the best possible direction.
Scroll down to the bottom of the file and uncomment the code. Run it to see how Dijkstra’s path-finds in all directions, while A* uses its heuristic to focus the search in a particular direction.
Sign up to start coding