Graph Theory37 sections · 1633 units
Open in Course

Detection Strategy

The plan

How do you check if a graph is bipartite?

Try to 22-color it. If you succeed, it is bipartite. If you hit a contradiction (two adjacent nodes with the same color), it is not. The algorithm is simple: pick a node, assign it color 00. All its neighbors get color 11. All their neighbors get color 00. Continue until done. If you ever need to color a node but its neighbor already has the same color, you have found an odd cycle. The graph fails the test. If you finish without conflicts, the graph is bipartite.