Why are we checking this condition - child!=par?

I am not able to understand that why are we checking this condition child!=par in the else if statement.

I think that child and parent nodes will always have different color because we have already colored parent node and passed different color for child node.

Please help

hi @HemantKumar

as in the case of a cycle with odd number of nodes, you will see that the last node to be colored will HAVE to have a common color with either its parents or its child.