Guest User
Using app without sign in

Practice book
Graph Theory Through Problems300 Exercises with Hints, Worked Algorithms and Complete Solutions
By Mohammed Islam Hadjoudj
Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
Colour the most constrained vertex first
Greedy colouring that always colours the vertex whose neighbours use the most different colours
Select an algorithm and generate steps to begin visualization
DSatur is a greedy graph colouring algorithm published by Daniel Brélaz in 1979. Like every greedy method it gives each vertex the smallest colour its neighbours do not use, but it chooses the order as it goes: the next vertex is the one whose neighbours already show the most different colours, its saturation degree. Colouring the most constrained vertex first usually needs noticeably fewer colours than a fixed order.
At the start no vertex is coloured and every saturation is 0, so the vertex with the most neighbours goes first. After each step the saturations are updated: a vertex's saturation is the number of different colours among its coloured neighbours. The uncoloured vertex with the highest saturation is coloured next, ties broken by the number of uncoloured neighbours, and it gets the smallest colour that none of its neighbours has. The run ends when every vertex is coloured. A simple scan takes O(V²) time, a priority queue O((V + E) log V). DSatur is exact on bipartite graphs, cycles and wheels; in general minimum colouring is NP-hard and DSatur is a heuristic.
Graph colouring schedules exams and meetings without conflicts, assigns radio frequencies so that neighbouring transmitters do not interfere, allocates registers in compilers and solves Sudoku-like puzzles. DSatur is a standard baseline in timetabling and frequency assignment, and the starting point of exact branch-and-bound colouring algorithms. On this site it can be compared directly with Welsh-Powell greedy colouring.
DSatur, short for degree of saturation, is a greedy colouring that chooses its order on the fly. The next vertex is always the one whose neighbours already use the most different colours, since it is the most constrained.
DSatur(graph):
colour[v] = none for every v
while some vertex is uncoloured:
v = the uncoloured vertex with the largest saturation
// saturation = number of distinct colours among neighbours
// ties: most uncoloured neighbours, then first label
colour[v] = the smallest colour no neighbour of v uses
update the saturation of the neighbours of v
return colourPlain greedy colouring fixes the order in advance and can waste colours on vertices whose neighbours are still free. DSatur postpones decisions on easy vertices and colours the hard ones while choices are still open. The rule is known to be exact on bipartite graphs, cycles and wheels, and it performs well on many other graphs.
Colour the example this page loads, a crown graph on eight vertices chosen because plain greedy colouring in label order handles it badly.
Example graph: Two sides, A, C, E, G and B, D, F, H. Each vertex is joined to every vertex on the other side except its partner: A-D, A-F, A-H, C-B, C-F, C-H, E-B, E-D, E-H, G-B, G-D and G-F. Every vertex has degree 3.
DSatur colours the crown graph with 2 colours, A, C, E, G in colour 1 and B, D, F, H in colour 2, which is optimal. The difference from greedy colouring comes entirely from the order: by always picking a vertex next to an already coloured one, DSatur effectively traces out the two sides of the bipartition, while label order mixes them and pays with two extra colours.
Time: O(V^2), or O((V + E) log V) with a heap · Space: O(V + E)
Each of the V steps selects the uncoloured vertex with the highest saturation. Scanning all vertices costs O(V) per step, giving O(V^2). Choosing the smallest free colour for v and updating its neighbours costs O(deg(v)) with a set of neighbour colours per vertex, which totals O(E) over the run. Keeping the uncoloured vertices in a priority queue keyed by saturation and degree reduces selection to O(log V), and since each saturation can increase at most once per edge, the total becomes O((V + E) log V). Memory holds the colours and one set of seen colours per vertex.
Graph colouring is NP-hard, so every fast method is a heuristic. They differ in how much effort goes into the order.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Greedy (Welsh-Powell) | Speed is all that matters. Colour vertices in decreasing degree order with the smallest free colour. | O(V log V + E) |
| Recursive largest first (RLF) | Better colourings are worth more time. It builds one colour class at a time and often beats DSatur. | O(V^3) |
| Backtracking or branch and bound | You need the exact chromatic number on a small graph. DSatur ordering is the usual branching rule. | exponential |
| Tabu search (Tabucol) | Large hard instances such as timetabling, where a local search can improve the DSatur result. | tunable |
Related algorithms: Graph Coloring, Bipartite Check, Maximal Clique, Chordality Check