#C5760. Largest Group of Friends
Largest Group of Friends
Largest Group of Friends
In this problem, you are given a social network of (n) people with (m) friendship connections. Each connection represents a bidirectional friendship between two people. Two people are considered to be in the same group if they are directly or indirectly connected through these friendships. Your task is to find the size of the largest group of connected friends.
Formally, you are given an undirected graph with (n) nodes and (m) edges. Let (C_1, C_2, \dots, C_k) be the connected components of the graph. You need to compute (\max_{1 \leq i \leq k} |C_i|), where (|C_i|) denotes the number of nodes in the (i)th connected component.
You are required to read input from standard input (stdin) and write output to standard output (stdout). Efficient graph traversal methods such as Breadth-First Search (BFS) or Depth-First Search (DFS) can be applied to solve this problem.
inputFormat
The first line of input contains two space-separated integers (n) and (m), where (n) is the number of people and (m) is the number of friendship connections. The following (m) lines each contain two space-separated integers (u) and (v), indicating that there is a friendship between person (u) and person (v).
outputFormat
Output a single integer representing the size of the largest group of connected friends.## sample
5 3
1 2
2 3
4 5
3
</p>