b2KIT

Graph Coloring Tool

Color graphs with minimum colors (chromatic number). Build graphs and try to color them or let the algorithm find optimal coloring.

Tested tool guide Tested browser tools Checked August 16, 2026

What Graph Coloring Tool does, with a checked example

This tool turns graph coloring into something you can see and verify. Build a graph by adding vertices and connecting them with edges, then either color it yourself by clicking or let the tool search for an optimal coloring and report the chromatic number, the fewest colors that keep adjacent vertices different. Because the search tries every assignment, the reported number is the proven minimum, not a heuristic estimate. The surprise most users hit: a valid k-coloring you produce only proves k colors are enough. Whether fewer would work is a separate question, and on graphs like odd cycles the true minimum is usually smaller than a casual attempt suggests.

Worked example

A concrete input and expected output from the current implementation.

Input

5-cycle: vertices 1-5, edges 12, 23, 34, 45, 51

Expected output

Chromatic number 3. Sample coloring: color A = {1, 3}, color B = {2, 4}, color C = {5}.

The 5-cycle is an odd cycle, and odd cycles are exactly the graphs that cannot be split into two color classes, so 2 colors never work. The search finds a valid 3-coloring instead, and since no 2-coloring exists, 3 is the chromatic number.

How the result is produced

1

Manual coloring with conflict flags

Click or tap vertices to assign colors from the palette. The tool marks every edge whose two endpoints share a color, so you can iterate until the whole graph is clean. This mode is a puzzle: completing it proves the graph can be colored with the palette size you used, but nothing more. A successful attempt with k colors establishes only that k colors suffice.

2

Exhaustive search for the minimum

The tool's algorithm mode tests colorings with one color, then two, then three, and so on, checking every assignment at each step until a valid coloring appears. The first number that succeeds is the chromatic number, and the tool displays a witness coloring. Because the check is exhaustive, the result is exact; the cost is that search time grows explosively with vertex count.

Good uses

  • Exam prep: you hand-compute a chromatic number for a practice graph and want confirmation that no smaller coloring exists before trusting your reasoning.
  • Scheduling with conflicts: build a graph where an edge means two tasks cannot share a slot; the chromatic number is the minimum number of time slots needed, and the tool's coloring doubles as an actual schedule.
  • Bipartite checks: run the search and see whether the answer is 2 colors, which is exactly the test of whether a graph is bipartite, useful before assuming a network or relation splits into two disjoint groups.

Limits and checks

  • Upper bound versus minimum. Any valid coloring you produce, and any the tool shows you, proves only that its color count is enough. The chromatic number claim rests on the search failing at every smaller count, so a manual k-coloring alone never proves minimality.
  • The four color theorem is a ceiling for planar graphs only. Non-planar graphs can genuinely require 5 or more colors, and whether a graph is planar depends on whether its edges can be redrawn without crossings, not on how your current layout happens to look.
  • Search time explodes with size. Checking every assignment means each added vertex multiplies the work by the palette size, so expect near-instant answers on small graphs and a sharp slowdown as vertices accumulate. Keep exact searches to roughly a dozen vertices.

Common questions

My graph needs 5 colors, but I was told any map can be colored with 4. What went wrong?

The four color theorem guarantees 4 colors only for planar graphs, the ones that can be drawn with no crossing edges. A graph containing the complete graph K5 or the utility graph K3,3 is non-planar and can genuinely need more than 4. Your coloring is probably correct; the 4-color promise simply does not apply.

Is the graph I build stored or sent anywhere?

No. Coloring, conflict checking, and the search all run inside the browser page, and no data is sent anywhere. The practical consequence: your graph exists only while the page is open, so closing the tab discards it and you rebuild it next time.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools