Problem: Cycle detection in an undirected graph. Code not working

https://practice.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1# 1