Can the nodes be split into two teams?
Write is_bipartite(graph) that returns whether the nodes of the two-way graph can be
coloured with two colours so that no edge joins two nodes of the same colour. Every node
is a key.
is_bipartite({0: [1, 3], 1: [0, 2], 2: [1, 3], 3: [0, 2]}) -> True (a square)
is_bipartite({0: [1, 2], 1: [0, 2], 2: [0, 1]}) -> False (a triangle)
is_bipartite({}) -> True
The point is to practise BFS that assigns alternating labels and checks for conflicts.
def is_bipartite(graph):
...