Implemented directed DFS