plz tell if this code is right for this kind of questions …
also tell if we can use this code in directed graphs??
plz tell the reason as well. why we can or cant…
also tell if we can use this code in graphs with more than one components??plz tell the reason as well why we can or cant…
Detect cycle in graph using disjoint set union
Hey @S19LPPP0202
Yes your code for finding cycle in undirected graphs is correct
No this does not work with directed graphs for which there is another technique to find cycles which you can find on GFG
Reason you will understand once you read the article
Yes it can work on graphs with more than one components
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.