A DFS gives a simplest paradigm for the exploration of the connected components of a graph. Thus, on the highest level, a most convenient algorithmic solution should be based on DFS.