A* Algorithm
A* Search Algorithm is a simple and efficient search algorithm that can be used to find
the optimal path between two nodes in a graph. It will be used for the shortest path
finding. It is an extension of Dijkstra’s shortest path algorithm (Dijkstra’s Algorithm). The
extension here is that, instead of using a priority queue to store all the elements, we use
heaps (binary trees) to store them. The A* Search Algorithm also uses a heuristic
function that provides additional information regarding how far away from the goal
node we are.
Open Set: The open set is a collection of nodes that are candidates for evaluation.
Closed Set: The closed set contains nodes that have already been evaluated.
EXAMPLE:
Consider the weighted graph
Node (S-A):
f(A) = g(A) + h(A)= 1 + 3 = 4 // consider
Node (S-G):
f(S-G) = 10 + 0 = 10 // hold
Node (S-A-B):
f(B) = g(B) + h(B)= 3 + 4= 7 //hold
Node (S-A-C):
f(C) = g(C) + h(C)= 2 + 2= 4 //consider
Node (S-A-C-D):
f(D) = g(D) + h(D)= 5 + 6= 11 //hold
Node (S-A-C-G):
f(G) = g(G) + h(G)= 6 + 0= 6 //consider
Thus, the optimal path between the start node to goal node is S-A-C-G
Real-world Applications of the A* Algorithm
• GPS Navigation
• Video Games