Implementation is not cleared

the code is not cleared pleade help me

Hi @Bhavit_Singla,
int the code, we are just trying to see whether a cycle exist in the graph or not. If it exist, its not a tree else it is a tree.
So, in order to check for cycle, we apply bfs. Now, while applying bfs, if we come across a vertex which we have already visited and the node from which we are coming to the vertex is different from its parent then, we say cycle exist.
eg.
1-------2
\ /
\ /
3
here suppose we reach 2 and 3 from 1. so parent[2] and [3] is 1.
now when we check for 2, we reach 3, but parent[3]!=2, hence a cycle must be dere.
the same logic is being applied in the code.
Hope dis helps.
if something is not clear, please post ur doubts here