Doubt in cycle detection

how dose we get to know the cycle is present as both 2 and 6 are pointing to 0 but before that all other elements were also pointing to 0

hello @adarshsingh2k

intially parent of all node was -1 right?
and because now parent of 2 and 6 is same which is 0 .
we can say that they will form cycle.