color this pos as c and all its neighbours and 1 - c
color [ pos ] = c NEW_LINE ans = True NEW_LINE for i in range ( 0 , V ) : NEW_LINE INDENT if G [ pos ] [ i ] : NEW_LINE INDENT if color [ i ] == - 1 : NEW_LINE INDENT ans &= colorGraph ( G , color , i , 1 - c ) NEW_LINE DEDENT if color [ i ] != - 1 and color [ i ] != 1 - c : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if not ans : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE def isBipartite ( G ) : NEW_LINE color = [ - 1 ] * V NEW_LINE