DFS algortihm is incorrect. It iss only for tree.