pub fn connected_components(graph: &Graph) -> Vec<Vec<usize>>
Returns the connected components of the graph (treating all edges as undirected).
Uses union-find. Each component is a sorted list of node indices.