for x, i inenumerate(graph): for y in i: edge[x][y] = edge[y][x] = 1 for i inrange(0, size): if color[i] == 0: que.append(i) color[i] = 1 while que: curr = que.pop() has.append(curr) for i inrange(0, size): if edge[curr][i]: if color[i] == 0: color[i] = -color[curr] elif color[i] == color[curr]: returnFalse if i notin has: que.append(i) returnTrue