Understanding the connected component pattern
A connected component in a graph is a subgraph where there is a path between every pair of nodes. Connected components are usually used in the context of undirected graphs only. Directed graphs have more complex connectivity due to unidirectional edges, and such subgraphs where there is a path between every pair of nodes are called strongly connected components. We will only learn about connected components in undirected graphs in this lesson. Some graph problems require us to find all and process all the connected components and the nodes in them in an undirected graph. We can solve such problems efficiently using the connected component technique.
An undirected graph with three connected components.
Liking the course? Check our discounted plans to continue learning.