#K62382. Largest Reach in ByteLand
Largest Reach in ByteLand
Largest Reach in ByteLand
In ByteLand, there are n people numbered from 1 to n and m bidirectional friendships. Two people can communicate if there is a direct friendship between them or if there is a chain of friendships linking them.
Your task is to find the size of the largest group of people (i.e. the largest connected component) that can communicate with each other.
Note: Self loops (a person being friends with themselves) might be present and should be handled appropriately.
Mathematical Formulation: Let \(G(V, E)\) be an undirected graph where \(V = \{1, 2, \ldots, n\}\) is the set of people and \(E\) is the set of friendships. The answer is the maximum size of a connected component in \(G\).
inputFormat
The first line contains two integers n and m separated by a space, where n (1 ≤ n ≤ 105) is the number of people and m (0 ≤ m ≤ 105) is the number of friendships. Each of the following m lines contains two integers u and v indicating that person u and person v are friends. If m is 0, there will be no additional lines.
outputFormat
Output a single integer representing the size of the largest connected component (largest reach) in ByteLand.
## sample5 4
1 2
2 3
3 4
5 5
4