Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Sat Feb 22 16:08:35 2020
- @author: Faisal Ahmed
- """
- print("DFS Algo")
- graph={
- 'A' :['B','C'],
- 'B' :['D','E'],
- 'C' :['F'],
- 'D' :[],
- 'E' :['F'],
- 'F' :[]
- }
- visited=[]
- def dfs(visited,graph,node):
- if node not in visited:
- print(visited)
- print("\n")
- print (node)
- print(".........")
- visited.append(node)
- for neighbour in graph[node]:
- dfs(visited,graph,neighbour)
- dfs(visited,graph,'A')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement