PythiloMedium · 25 min · Task 84 of 100 · progress kept in this browser

Check a bipartite graph

Return whether an undirected graph can be colored with two colors so adjacent vertices differ. The dict includes every vertex and symmetric adjacency; disconnected graphs and self-loops are permitted.

colors = {0: 0}
node, neighbour = 0, 1
colors[neighbour] = 1-colors[node]
print(colors)
Your task

Return whether an undirected graph can be colored with two colors so adjacent vertices differ. The dict includes every vertex and symmetric adjacency; disconnected graphs and self-loops are permitted.