What if your graph is not one connected piece?
Imagine islands in an ocean. Bridges connect some islands, but not all. Each cluster of connected islands is a component. In graph terms, a connected component is a maximal set of vertices where every pair is reachable from each other. If you have vertices with edges and , there are two components: and . Counting components is a common problem. DFS makes it easy.