• It is connected
• It has no cycle.
If n = 5 and if there are 4 edges i.e [ [0, 1], [0, 2], [0, 3], [1, 4]] so the graph formed will look like this:-
Here this graph is connected and it has no cycle so it is a tree.
The first line of input contains an integer T’ denoting the number of test cases to run. Then the test case follows.
The first line of each test contains an integer ‘N’ where N is the number of nodes.
The next line of each test case contains an integer ‘M’ where M is the number of edges.
Then the following m lines contain two space separated integers each representing the list of undirected edges.
For each test case, print "True" if the graph is a valid tree otherwise print "False".
You don’t have to take input or print anything. This already has been taken care of. Just implement the function.
1 <= T <= 5
1 <= N <= 10^3
1 <= M <= 10^3
For a graph being a tree, we have to check the following things
Minimum Swaps To Make Identical Array
Find Center of Star Graph
Critical Connections in a Network
Critical Connections in a Network
Critical Connections in a Network
Critical Connections in a Network
COUNT ISLANDS
Distance to a Cycle in Undirected Graph