finished graph DFS algorithm