Four things to remember:
Use an array to track colors. Initialize to for "unvisited."
The color flip trick 1 - c alternates between and cleanly.
Check all neighbors: if same color, return false immediately.
Handle disconnected graphs with an outer loop over all nodes.
This is the core bipartite detection pattern. Every variation uses the same idea: try to -color, fail if you find a conflict.