The objective of PA2 is to write a Python program that traverses graphs in BFS and DFS manner. BFS will determine the distance from the root, DFS will find cycles in the graph. Study the lecture on graphs, in particular graph traversals The Checkin tab on the course website will perform preliminary testing of your code. These tests do not indicate your final grade. They can, however, catch mistakes in your submission. You can re-submit your file as often as you want.

Download dfbf.txt, and rename it dfbf.py. Some starter code is provided. Don't change it. It is your job to implement DFS and BFS. When visiting children of a node, visit them in left to right order, i.e., if adj is the adjacency list of a node, visit the children as follows for nxt in adj:

Testing your code

When provided with in1.txt,
python3 dfbf.py in1.txt a
should produce output.txt.