Implemented DFS for undirected graphs