## Sudoku as a coloured graph

Prereqs: Just the definition of a graph – vertices, edges and adjacent vertices.

2 years back I gave an exposition on counting the number of unique sudokus, which are not related to each other by the usual symmetry transformations like permuting cells, rows, etc. No more on that. You can read everything you want to know about this on http://www.afjarvis.staff.shef.ac.uk/sudoku/. By the way, the number is **6670903752021072936960**. Yes, it’s large enough to be comforted that you have enough unique sudokus to solve all your life. Unless you’re a computer.

Today I was thinking about how people can build a “well formed” sudoku (that is, one with a unique solution). People, mind you, not a sudoku-builder program that uses incremental or decremental generation to come up with a valid sudoku.

What is the minimum number of elements one needs to specify for the sudoku to have a unique solution?

This is not at all an easy question to answer. You may answer it with some work for a sudoku perhaps, but as you increase the size the question becomes way harder. After thinking and searching for whatever literature I could find about this, I stumbled upon the most elegant solution I’ve seen in a while (Alright, I haven’t seen much. Granted. But this got me intrigued.) I shall discuss below the solution as proposed by Herzberg and Ram Murty in their paper.

** Trivia**: The minimum number is

*atmost*17. Nobody knows if a sudoku with 16 entries to start with can have a unique solution.

**Basic graph theory in a nutshell: **I will not be writing about this but you can go to the hyperlink if you need a refresher.

_________________________________________

**A sudoku as a coloured graph:
**

** **A coloured graph is a set of vertices and edges, with an addition variable called “colour” which each vertex is assigned. How do we view a sudoku as a coloured graph?

Consider the usual sudoku. Number all the cells from 1 through 81. These are your vertices. Now connect them as follows: each vertex is connected to all vertices in the same row, column and square ( by square I mean the squares that the sudoku is made up of.) Introduce 9 colours (Girls have the added advantage for visualization here as there are more complex colours on their palette – fuschia, turquoise and what not). Now assign each cell a colour out of these 9. To solve a sudoku, you need to assign these colours such that no two connected vertices have the same colour!

Let’s state this formally.

**Proper colouring of a graph**

A colouring of a graph G is a map f from the vertex set of G to {} . This is called a proper colouring if f(x) f(y) whenever x and y are adjacent in G (Adjacent means that the two vertices of the graph are connected by an edge). So a sudoku puzzle is basically an incomplete colouring( called a partial colouring) which the solver needs to complete.

To quote the experts,

“A Sudoku puzzle corresponds to a partial coloring and the question is whether this partial coloring can be completed to a total proper coloring of the graph”

Does that make you

I hope it does, because otherwise it would imply I have a bad taste in exciting math problems. Anyway, back to work.

_______________________________

A regular graph is one in which the degree of each vertex ( i.e. the number of vertices it is connected to) is the same. Any sudoku is a regular graph of degree

Now for the punchline – the theorems which answer our question. I will simply state the 2 brilliant theorems here. You can read their equally brilliant proofs in the original paper.

**Theorem 1: **Let G be a finite graph with v vertices. Let C be a partial colouring of t vertices of G using colours. Let () be the number of ways of completing this colouring by using colours to obtain a proper colouring. Then () is a monic polynomial in with integer coefficients of degree v-t for

**Implications: **The number of ways of completing our sudoku is (9)* .* A unique solution is quaranteed if and only if (9)=1.

____________________________________________

The minimal number of colours required to properly colour the vertices of a graph G is called the ** chromatic number** of G and denoted

____________________________________________

**Theorem 2: **Let G b a graph with chromatic number and C be a partial colouring of G using only colours. If the partial coloring can be completed to a total proper coloring of G, then there are at least two ways of extending the colouring.

**Implications**: If C is a partial colouring of G that can be uniquely completed to a proper total colouring, then C must use *at least * colours. So for our sudoku, at least 8 colours must be used in the given cells for the sudoku to be “well formed”

Note that with these theorems you can make statements about sudokus of all sizes!

____________________________________________

**References:**

interesting!

This might be stupid, but is theorem 2 true because if the partial coloring uses x(G)-2 colors then we can interchange the remaining two colors in the full coloring?

@Saket: Yes, you are right. That’s how they prove it in the paper.

Tejal: Sorry Saket, I didn’t read your comment correctly. Yes you are right. It is not unique since the 2 colours can be interchanged.

On a different note, we know that the sudoku has 81 vertices, each of which is adjacent to 20 others. With just this much information, is it possible to deduce that its chromatic number is 9? In other words, can we say that any general graph of 81 vertices each of which is adjacent to 20 others has a chromatic number 9?

Tejal: The only “structure” that a graph has is the skeleton of vertices and edges and how they are connected. So the chromatic number has to be a function of these alone. I do not know the exact dependence but it doesn’t seem trivial at all. You can look at this

It is an NP-hard problem!

Perhaps you know about this already, but Gary McGuire et al. showed (using clever algorithms and heavy computations) that 17 is indeed the minimum number of entries required to ensure unique solution: https://arxiv.org/abs/1201.0749, http://www.math.ie/checker.html.