Computer program for coloring networks with a given number of colors
(University of Exeter, Jan Sieber)
The part below uses the mathematical programming environment sage
(www.sagemath.org/). The
cells with the numbered lines are programming code, which will be
executed on the free cloud
service sagecell.sagemath.org/
-
Below is a piece of computer program that performs automatically what
a human would do manually when coloring a network.
Suppose we have
colored nodes up to number n-1, so we are trying to find a color for
node number n. We check, which colors the neighbors have, choose
the next available color for node n, and move on to node n+1. If no
color is available, we move back to node n-1 and see if we had another
color choice there.
Click 'Execute code' to load this function.
Some other functions that are useful and needed are loaded below (feel free to ignore or explore).
Click 'Execute code' to load these extra functions.
- I have prepared two ways to type in how the network looks. The
first way is as a sequence of number node number pairs connected
with a hyphen (or minus). This sequence needs to be enclosed by
three doublequote marks as the text after links= below.
Click 'Execute code' to run the code.
- An alternative way is to input the network directly. Be aware
that this requires curly braces, colons, square brackets and commas
in the right places. For example, if node 1 is linked to nodes 2, 3
and 4, one has to write 1:[2,3,4].
Move on to sudoku solving.