Checking a Graph with Two Colors

A graph is bipartite when vertices can be assigned one of two parts and every edge crosses between the parts.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Color a short chain
  2. Find an odd cycle obstruction
  3. Propagate alternating colors and inspect contradictions
  4. Start again in each uncolored component

Color a short chain

In A–B–C–D, assigning A and C to the first part and B and D to the second works. Adding A–D still crosses the parts. Undirected connections require both ends of each edge to be examined consistently.

Find an odd cycle obstruction

On a triangle, A and B must differ and B and C must differ, forcing A and C to agree despite their edge. See cycle witnesses for reporting that specific obstruction.[1]

Propagate alternating colors and inspect contradictions

In square A–B–C–D–A, color A blue. Its neighbors B and D must be gold, which forces C to be blue. Adding diagonal A–C makes two adjacent vertices share blue under the forced assignments. See connected components.

A blue → B gold → C blue
D gold meets both C and A
A–C check with added diagonal: blue versus blue → conflict

Start again in each uncolored component

An isolated vertex can receive either color. An odd cycle cannot be colored because alternating along it forces opposite colors for the start on return. An undirected self-loop also gives an immediate conflict. Test both valid and conflicting components together.

References

  1. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩