Connect Component

  • A undirected subgraph in which any two vertices are connected to each other by paths, and which is connected to no additional vertices in the supergraph. For example, the following graph has 3 connected components.

  • English Algorithm

    • Beginning with some node s, traverse through the graph using either BFS or DFS. Maintain enum labels for visited/non-visited nodes to avoid cycles.

    • Continue performing traversals on unvisited nodes until all nodes are visited. A single traversal will find an additional connected component.

Last updated