Count the connected components that are complete in an undirected graph with n vertices labeled 0 through n - 1. Each pair [u, v] in edges connects those two vertices in both directions.
A connected component contains all vertices reachable from any one of its vertices. It is complete when every pair of distinct vertices in the component has a direct edge between them.
An isolated vertex is a complete component of size 1. Count whole connected components, not smaller complete subgraphs inside them.
Example 1:
Input: n = 5
edges = [[0,1],[1,2]]
Output: 2Explanation: The component {0,1,2} is not complete because edge [0,2] is missing. Vertices 3 and 4 are isolated, and each is a complete one-vertex component, giving 2.
Example 2:
Input: n = 4
edges = [[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
Output: 1Explanation: All six pairs of vertices in the only component have direct edges. That whole component is complete, so the answer is 1.
Example 3:
Input: n = 5
edges = [[0,1],[2,3]]
Output: 3Explanation: The components {0,1} and {2,3} each contain their one required edge. Vertex 4 is isolated and also complete, giving 3 complete components.
Constraints:
1 <= n <= 500 <= edges.length <= n * (n - 1) / 2edges[i].length == 2- Edge endpoints are distinct vertex labels between
0andn - 1. - No undirected edge appears more than once.