Professional Documents
Culture Documents
Handout 3 BFS
Handout 3 BFS
Handout 03
Artificial Intelligence (CS-632) Class: BSCS 6
Code:
graph = {
'5' : ['3','7'],
'3' : ['2', '4'],
'7' : ['8'],
'2' : [],
'4' : ['8'],
'8' : []
}
Handout 03
Artificial Intelligence (CS-632) Class: BSCS 6
visited.append(node)
queue.append(node)
# Driver Code
print("Following is the Breadth-First Search")
bfs(visited, graph, '5') # function calling