Finding all disconnected subgraphs in a graph
I think what you are looking for is generally called a Flood Fill. It is up to you whether you traverse the graph through a BFS or a DFS. Basically you take an unlabeled (AKA uncoloured) node and assign a new label to it. You assign the same label to all nodes adjacent to that … Read more