Adding isConnected and DFS.