Implemented DFS, BFS and cyclic check.