Skip to main content

Connected Components

Learn Connected Components (Graphs, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Finding Separate "Islands" in a Graph A connected component is a maximal set of vertices all reachable from each other. Finding all components: run DFS (or BFS) from any UNVISITED vertex, marking everything it reaches as one component, and repeat from the next unvisited vertex until all vertices are covered.

More lessons in Graphs