#K46342. Graph Connectivity Check
Graph Connectivity Check
Graph Connectivity Check
Given an undirected graph with \( n \) nodes and \( m \) edges, determine whether the graph is fully connected. A graph is considered fully connected if there is a path between any two nodes.
You are given multiple test cases. For each test case, the first line contains two integers \( n \) and \( m \). Each of the following \( m \) lines contains two integers \( u \) and \( v \), indicating that there is an edge between node \( u \) and node \( v \). The input terminates with a line "0 0", which should not be processed.
inputFormat
The input consists of multiple test cases. Each test case begins with a line containing two integers \( n \) and \( m \), where \( n \) represents the number of nodes and \( m \) represents the number of edges. This is followed by \( m \) lines each with two integers defining an edge between two nodes. The input ends with a line containing "0 0".
outputFormat
For each test case, output a single line containing "YES" if the graph is fully connected, and "NO" otherwise.
## sample1 0
0 0
YES