Algorithm
Weakly connected components
activeNeeds verification
Finds groups of nodes connected when edge direction is ignored; often the first data-quality check on a new graph.
Intuition
Flood-fill from each unvisited node (BFS/DFS) or merge endpoints with union–find; every flood is one component.
Complexity
| Time | O(V + E) |
|---|---|
| Space | O(V) |
Python
import networkx as nx
comps = list(nx.weakly_connected_components(DG))Cypher (Neo4j GDS)
CALL gds.wcc.stream('myGraph')
YIELD nodeId, componentId RETURN componentId, count(*) AS sizeProcedure names and options vary between GDS versions; check the GDS docs for your version.
An interactive step-by-step visualizer for this algorithm is planned for phase 3.
Profile
| Time complexity | O(V + E) |
|---|---|
| Space complexity | O(V) |
Relationships
- Belongs to
- Applied to
- Prerequisites
- Breadth-first search (BFS)(Algorithm)
- Implemented by
- GraphFrames(Library / framework)