#C4181. Largest Connected Component
Largest Connected Component
Largest Connected Component
You are given an undirected graph with N nodes labeled from 1 to N and M edges. Your task is to calculate the size of the largest connected component in the graph.
A connected component is a subgraph in which any two vertices are connected to each other by paths. In mathematical terms, if C is a connected component, then the answer is:
\(\max_{C \subseteq V} \lvert C \rvert\)
where \(V\) is the set of all nodes and \(\lvert C \rvert\) denotes the number of nodes in component C.
The input will be read from standard input and the output should be printed to standard output.
inputFormat
The first line contains two integers N and M separated by a space, where N is the number of nodes and M is the number of edges in the graph.
The next M lines each contain two integers u and v (1-based indices) indicating that there is an undirected edge between node u and node v.
outputFormat
Output a single integer which denotes the size of the largest connected component in the graph.
## sample5 3
1 2
2 3
4 5
3
</p>