Graph coloring usually means vertex coloring: assign a color to each vertex so that adjacent vertices do not share a color. The smallest number of colors that works is the chromatic number, written .
If you want the fast intuition, colors are just conflict-free labels. Two vertices can reuse the same color exactly when there is no edge between them.
Graph coloring definition in one minute
In a proper coloring, every edge connects two differently colored vertices. That is the whole rule.
So if , two facts are true at the same time:
- a proper coloring with colors exists
- no proper coloring with only colors exists
That is why the chromatic number is a minimum, not just the number of colors you happened to use in one drawing.
Unless someone says otherwise, graph coloring in an intro course means coloring the vertices of a simple undirected graph. Edge coloring is a different problem with different rules.
What the chromatic number is really measuring
The color names do not matter. You can use red, blue, and green, or labels , , and .
What matters is the grouping. All vertices with the same color form a set with no edges inside it, so that group has no conflicts.
That viewpoint is what makes graph coloring useful in scheduling and allocation problems. One color often means "these items can share the same slot."
Worked example: why a 5-cycle needs 3 colors
Consider the cycle graph with edges and .
Try colors first. Give color and color . Then the coloring is forced around the cycle:
Now look at . It is adjacent to both and , so it cannot use color because of , and it cannot use color because of .
So colors fail.
But colors do work. One proper coloring is
so
This example is worth remembering because it shows an important pattern: for cycle graphs, an even cycle can be colored with colors, but an odd cycle needs .
How to reason about graph coloring on small graphs
Two quick checks help.
First, look for a forced conflict. In the example above, alternating two colors around an odd cycle makes the last vertex clash with both available choices.
Second, look for a lower bound. If a graph contains a triangle, then those three vertices are pairwise adjacent, so they already need different colors. That does not always give the exact answer, but it proves the chromatic number is at least .
Common mistakes in graph coloring problems
One common mistake is treating vertices as adjacent just because they are drawn close together. Only an actual edge creates a coloring restriction.
Another mistake is assuming every vertex needs its own color. Nonadjacent vertices can reuse a color, and efficient colorings usually reuse colors as much as possible.
Students also sometimes mix up vertex coloring and edge coloring. In this page, the rule is about adjacent vertices, not adjacent edges.
A final mistake is reporting the number of colors you happened to use instead of the minimum number required. Using colors on a graph does not prove the chromatic number is .
Where graph coloring is used
A standard application is scheduling. Suppose each vertex is an exam, and an edge means two exams share students and cannot be placed at the same time. Then one color can represent one time slot.
In that model, the chromatic number tells you the fewest time slots possible. If , then no valid schedule with only slots exists.
The same idea appears in map coloring, where neighboring regions must differ, and in compiler design, where variables that are simultaneously needed cannot share the same register.
Try a similar graph coloring problem
Draw a graph with vertices and edges and .
Start by finding a triangle to get a lower bound. Then try to color the graph with as few colors as possible and check whether any adjacent vertices match. If you want a next step, try your own version on a larger graph and see whether you can prove your coloring is minimal, not just valid.
Need help with a problem?
Upload your question and get a verified, step-by-step solution in seconds.
Open GPAI Solver →