Graph Theory37 sections · 1633 units
Open in Course

Connected Components

Broken Graphs

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 {1,2,3,4}\{1, 2, 3, 4\} with edges 121-2 and 343-4, there are two components: {1,2}\{1, 2\} and {3,4}\{3, 4\}. Counting components is a common problem. DFS makes it easy.