<<< Bangladesh Competition Commission | Programmer | Written Test - 2019 | Exam Taker - DU

1. Start with an arbitrary vertex and assign it a color (e.g., color "0").

2. Traverse the graph using Breadth-First Search (BFS) or Depth-First Search (DFS), and assign colors alternately to adjacent vertices that haven't been colored yet.

3. If at any point you encounter an edge connecting two vertices of the same color, then the graph is not bipartite. If all edges satisfy the coloring condition, the graph is bipartite.

Or,