Number of Connected Components in an Undirected Graph
Medium
Depth-First Search
Breadth-First Search
Union Find
Graph
You have a graph of `n` nodes. You are given an integer `n` and an array `edges` where `edges[i] = [aᵢ, bᵢ]` indicates that there is an edge between `aᵢ` and `bᵢ` in the graph.
Return *the number of connected components in the graph*.