#K64897. Largest Connected Component

    ID: 32077 Type: Default 1000ms 256MiB

Largest Connected Component

Largest Connected Component

Given an undirected graph with \(N\) vertices and \(M\) edges, your task is to compute the size of the largest connected component. A connected component is a set of vertices in which every pair of vertices is connected by a path.

The input graph is provided as two integers \(N\) and \(M\) on the first line, followed by \(M\) lines each containing a pair of integers representing an undirected edge between vertices \(u\) and \(v\). Vertices are numbered from 1 to \(N\).

inputFormat

The first line contains two integers (N) and (M), where (N) is the number of vertices and (M) is the number of edges. Each of the following (M) lines contains two integers (u) and (v), representing an undirected edge between vertices (u) and (v).

outputFormat

Output a single integer representing the size of the largest connected component in the graph.## sample

6 5
1 2
2 3
4 5
5 6
6 4
3