# Making art with the Travelling Salesman Problem

The Travelling Salesman Problem is a classic problem in mathematics. The objective of the problem is to find the shortest possible route between a number of cities that visits each city only once and returns to the starting point.

Below is a rendering of the text “MrReid.org” created by solving the Travelling Salesman Problem. If you look carefully you can see that in each case the text is composed of one single line, drawn “without lifting the pen from the page”.

Top to bottom: “MrReid.org” rendered using 1000, 2000, and 5000 nodes. Click to enlarge.

By taking a greyscale image, and turning it into a weighted Voronoi diagram (using Adrian Secord’s algorithm) it is possible to create a “map” in which the “cities” are placed closer together in dark areas and further apart in light ones.

Top: the original panda image. Bottom: weighted Voronoi diagram of panda image (10000 nodes).

By solving the Travelling Salesman Problem for this “map” (using the Nearest Neighbour algorithm for the first pass and and the 2-opt algorithm for subsequent optimisation) the following “route” is produced.

There isn’t really enough contrast between the background and foreground in the original panda image, but it works if you squint a little bit.