Undirected graph cycle detection using DFS

my output is not giving correct i tried find the error help me please

Hi @sandeep021,
pls share ur code using ide.codingblocks.com inorder to find the problem in ur code.

link: https://ide.codingblocks.com/s/191494

@sandeep021, in ur add edge function,change
adjlist[u].push_back(v);
if(bidir) adjlist[u].push_back(u);
to
adjlist[u].push_back(v);
if(bidir) adjlist[v].push_back(u);
Ur code will work fine.
Hope dis resolves ur doubt.

thank you sir i would have never found it