TITLE: Problems reducing to a graph-theory algorithm
QUESTION [6 upvotes]: This is essentially a question in pedagogy -- the answers could be useful to teach (or rather, motivate) graph theory, and especially the algorithmic side of it.
I have been very impressed with this example:
Question: What is the maximum size of a set of integers between 1 and 100 such that for any pair (a,b), the difference a-b is not a square ?
The first, naive algorithms that spring to mind to solve this (finite) problem are awkward. However, let me quote: " This problem can be defined as a Graph problem : we create a vertex for each integer, and link two integers if their difference is a square. We but have to find a maximal independent set in this graph ! "
Using this, a few trivial lines of Sage code give the answer (see the link). Sooo much time is saved for the coder!

Are there more examples like this one?

To be more precise, I'm looking for problems which:

do not immediately involve graph theory, on the surface,
reduce, after a little translation, into a common problem in graph theory (find a matching, find a colouring...). 
there should be a "haha!" effect for the mathematician, and a sigh of relief for the programmer.

I heard another nice one in a talk by Tim Gowers. A university wants to organize its exams. Some students take several exams. Some rooms and some time slots are available. Help them. Solution: each exam (maths, physics, etc) is a vertex; place one edge between exams if there is one student taking both; define "colours" to be pairs (room, time). Now you have to colour the graph such that adjacent vertices are in different colours.
There is a fine line between these great examples, and the articifial ones which I find disappointing, such as "$n$ couples having each $k$ children all want to shake hands on different days such that...". In fact, I should add that I'm certain to have a preference for problems involving maths (like the first one above) rather than "real life" (like the second).
Usual precaution: if this is not appropriate for MO, let me know and I will not be offended!

REPLY [4 votes]: I expected a flood of responses to this question, since there are so many lovely examples. That flood does not seem to have materialised yet, so let me add an old classic. I hope it isn’t too famous to be worth mentioning, and that adding it as a separate answer is the correct protocol.
I’m thinking of Steve Fisk’s celebrated proof of the Art Gallery theorem, which is in the form of an algorithm.
We are given the floor plan of an art gallery as a simple polygon in the plane with $n$ vertices, and we wish to place some (motionless point) guards into the polygon so that the whole of the interior of the polygon is visible to at least one guard.
We can see that we may need as many as $\lfloor\frac n3\rfloor$ guards by considering comb-shaped polygons with $n=3k$ vertices:

(There must be a guard in each of the grey triangles, and there are $k$ disjoint such triangles, so we need at least $k=\frac n3$ guards.)
The problem, then, is to place no more than $\lfloor\frac n3\rfloor$ guards into a simple polygon with $n$ vertices in such a way that one of the guards can see any point in the interior of the polygon.
Fisk’s algorithm is as follows: triangulate the polygon to obtain a planar graph whose vertices are the vertices of the original polygon and whose faces are triangles, and then three-colour the vertices so each face has a vertex of each colour. At least one of the three colours occurs $\leq\lfloor\frac n3\rfloor$ times: position guards at the vertices that are painted this colour. Since each triangle has a guard at one of its vertices, and a triangle is entirely visible from any one of its vertices, the whole of the polygon must be visible to at least one guard.
Thus a difficult-sounding purely geometric problem is solved by three-colouring the vertices of a planar graph.

I should perhaps note that prolific MO contributor Joseph O’Rourke literally wrote the book on art gallery theorems and algorithms.