AI Exp-3
AI Exp-3
Program:
from collections import deque
while queue:
# Get the first path from the queue
path = queue.popleft()
# Add paths with the neighbors of the current node to the queue
for neighbor in graph.get(node, []):
new_path = list(path)
new_path.append(neighbor)
queue.append(new_path)
OUTPUT:
Path from 'A' to 'H': ['A', 'B', 'E', 'H']