Task 3
Task 3
Task 3
A* Algorithm
Aim : To implement of A * Algorithm to find the optimal path using Jupiter
notebook.
Algorithm:
Step 1: start
Step 2: Place the starting node into open and find its f(n) [start node] value.
Step 3: Remove the node from OPEN, having the smallest f(n) value, if it is x
goal node, then stop and return to success.
Step 4: Else remove the node from OPEN, and find all its successors.
Step 5: Find the f(n) value of all the successors, Place them into OPEN and place
the removed node into close
Step 6: Go to step 2.
Step 7: Exit.
Program :
if n is None:
print('Path does not exist!')
return None
# define function to return neighbors and their distances from the passed node
def get_neighbors(v):
if v in Graph_nodes:
return Graph_nodes[v]
else:
return None
Result:
Thus the Implementation of A * Algorithm to find the optimal path using Python
Was successfully executed and output was verified.