MethodMath
DA
May 16, 2026

How to prove a graph is bipartite using graph coloring?

I need to understand the relationship between bipartite graphs and 2-colorability.

A graph G=(V,E)G = (V, E) is bipartite if its vertices can be partitioned into two sets V1V_1 and V2V_2 such that every edge connects a vertex in V1V_1 to a vertex in V2V_2.

The theorem states: A graph is bipartite if and only if it contains no odd cycles.

How would I prove this? Also, given a graph, what algorithm can I use to determine if it's bipartite?

For example, is this graph bipartite?

  • Vertices: {1,2,3,4,5}\{1, 2, 3, 4, 5\}
  • Edges: (1,2),(2,3),(3,4),(4,5),(5,1),(1,3)(1,2), (2,3), (3,4), (4,5), (5,1), (1,3)
1 answers405 views
Loading comments...

1 Answer

RF
Robert FischerMay 16, 2026 Accepted
**Theorem:** A graph is bipartite iff it has no odd cycles. **Proof (one direction):** If $G$ is bipartite with partition $(V_1, V_2)$, any cycle must alternate between $V_1$ and $V_2$, so it must have even length. Thus, no odd cycles. **Proof (other direction):** If $G$ has no odd cycles, pick a vertex and color it black. BFS from it: color each vertex the opposite of its parent. If we ever try to color a vertex already colored oppositely, we've found an odd cycle (contradiction). So the coloring succeeds, giving a bipartition. **Algorithm (BFS-based):** 1. Pick any starting vertex, color it 0 2. BFS: for each neighbor, color opposite of current vertex 3. If a neighbor already has the same color, graph is NOT bipartite 4. If BFS finishes without conflict, graph is bipartite with colors as partition **Your example:** Graph with vertices $\{1,2,3,4,5\}$ and edges $(1,2),(2,3),(3,4),(4,5),(5,1),(1,3)$. Start at 1 (black). 2 is white, 3 is black (from 2). But wait, 3 is also adjacent to 1 (black), and we're trying to color it black from edge (1,3). Conflict! So this graph is **not bipartite**, which makes sense since (1,2,3) forms a triangle (3-cycle).
Loading comments...
Login or Register to post an answer