Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 5

A* algorithm in Ai

Kapil 170/20 Btech CSE


Introduction
• It is a searching algorithm that is used to find the shortest path
between an initial and a final point.
• A* algorithm is a informed search means it uses the
 Heuristic function
• The informed search algorithm is more useful for large search space.
Informed search algorithm uses the idea of heuristic, so it is also
called Heuristic search.
Heuristic function
• In A* search algorithm, we use search heuristic as well as the cost to
reach the node. Hence we can combine both costs as following, and
this sum is called as a fitness number.
Example
Consider the weighted graph depicted above, which contains nodes and
the distance between them. Let's say you start from A and have to go to 6
D.

Now, since the start is at the source A, which will have some
initial heuristic value. Hence, the results are
2
f(A) = g(A) + h(A)
f(A) = 0 + 6 = 6

Next, take the path to other neighbouring vertices :


f(A-B) = 1 + 4 4
f(A-C) = 5 + 2

Now take the path to the destination from these nodes, and
calculate the weights : 0
f(A-B-D) = (1+ 7) + 0
f(A-C-D) = (5 + 10) + 0

It is clear that node B gives you the best path, so that is the node
you need to take to reach the destination.

You might also like