Technique
Bipartite Check / 2-Colouring
BFS/DFS colouring with alternating colours; a conflict means an odd cycle and the graph is not bipartite.
Learn firstGraph BFS / DFSUnlocksBipartite Matching
0%
mastery
0/5 solved
0/5 solved
Recognise it
The signal
split into two groups with no conflicts inside a group
1Brute force
Try all 2n splits.
2The observation
Exponential splits: colouring is forced along each edge.
3Why it works
Adjacent coloured vertices always have different colours.
Reach for it when
- +possible bipartition / dislike pairs
Not when
- ×more than two groups (k-colouring is NP-hard in general)
- ×parity constraints with weights (DSU with parity)
Practice
0/5 solved
- Building TeamsCSESEasy
- Is Graph Bipartite?Meta, AmazonMedium
- Split Into Two SetsCodeforces1600
- Graph Without Long Directed PathsCodeforces1700
- Bipartite CheckingCodeforces2500
Pitfalls
Misconceptions
- !only checking the component of vertex 0