Stay organized with collections Save and categorize content based on your preferences.

C++ Reference: connected_components

Note: This documentation is automatically generated.

Finds the connected components in an undirected graph:

If you have a fixed graph where the node are dense integers, use GetConnectedComponents(): it's very fast and uses little memory.

If you have a more dynamic scenario where you want to incrementally add nodes or edges and query the connectivity between them, use the [Dense]ConnectedComponentsFinder class, which uses the union-find algorithm aka disjoint sets: