Examples
Input: num = 6, edges = [[0,1],[4,5],[2,4],[1,3],[0,2]]
Output: 1
Explanation: All nodes are connected.
Input: num = 3, edges = [[0,1],[1,2]]
Output: 1
Explanation: All nodes are connected.
Input: num = 4, edges = [[0,1],[2,3]]
Output: 2
Explanation: There are two connected components: {0, 1} and {2, 3}.