Does not understand the else if statement

else if (nbr!=parent && color==visited[nbr]). don’t it means parent and child can have same color. or why we need to checkl whether it is it parent or not ???

While assigning colors, if we find a neighbor which is colored with same color as current vertex, then the graph cannot be colored with 2 vertices (or graph is not Bipartite)
Parent of the current node is also a neighbor of the current node so you are just avoiding repetition here as its already been assigned a different color since its a child of the parent node

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.