ECS 110 - Spring 1997

Homework 4 - Red, White, Blue, GOLD

Due 11:59 PM, Friday, June 6, 1997



Important reminder

Sorry; no late homeworks will be accepted.

Overview

In 1976 Kenneth Appel and Wolfgang Haken proved one of the most celebrated mathematical results of the century: that every planar map can be four-colored. This theorem means the following. Suppose you draw a map on a piece of paper (or a sphere), making a bunch of regions (e.g., states), each of which is a single connected piece. Then it is possible to paint the different regions with just four colors -red, white, blue, and gold- making sure that no neighboring regions get the same color. (Regions are neighboring if they share a true border; if they intersect in just a finite number of points, that doesn't count.)

Consider the following possibility. You've decided to leave computer science and go into business as an apprentice map maker. Your boss -who is familiar with Appel and Haken's work- only keeps four colors of paint in the office. Red, white blue, and gold. As your first assignment your boss comes in and shouts:

Hey, dummy! Here's a map of the lower-48 states of the U.S. Go paint the the states for me, using Red, White, Blue and Gold. No neighboring states with the same color. And one more thing: don't use Gold for more states than you have to! The stuff is damn expensive!

You think about quitting; your boss is clearly insane. But then you remember that you actually solved this problem in ECS 110. Your job is saved.

SO: your task is to write a program which, given a planar map, finds a four-coloring which minimizes the number of regions which receive the color "gold". You'll run your program on the lower 48 states of the United States (and any other maps we dig up for you). Your program will identify a best coloring, clearly indicating how many states -and which ones- get colored gold.

How to do it

Appel and Haken's proof actually gives an algorithm--a terribly complicated one--which runs in polynomial time and manages to color any planar map with just four colors. But you are not so lucky. Your problem, where you have to minimize the number of regions which gets one of the four colors, seems to be computationally much harder. In fact, this problem is believed not to possess any polynomial-time solution (same story as with homework 1). In fact, there is actually a theorem, due to Garey, Johnson and Stockmeyer (1976) which, in essence, indicates that it would be very surprising if you could solve this problem in time polynomial in the number of regions. If you could, then, for example, you could also have solved homework 1 by a polynomial time algorithm.

Fortunately, your input is pretty small so, if you're clever, you'll be able to solve this problem instance quickly even though you use an exponential-time algorithm. It would probably be best to use some kind of backtracking approach (see Weiss, section 10.5), but we leave it to you. Just make sure that your program always finds a best answer, and that it doesn't take more than a few seconds to color the lower 48 states of the USA.

You may find it useful to have a map of the USA to play with. This can aid in the discovery of a good coloring algorithm. Maps you can print out and color have been placed in ~cs110/hw4/usa48-portrait.html and ~cs110/hw4/usa48-landscape.html. Please include such a map with your writeup, colored-in using your computer-generated solution.

Format of Input and Output

The input graph (which is guaranteed to be planar) will be specified by an adjacency list. Each state will be named by a string of consecutive alphanumerics or underscores. First will appear a state and then, separated by blanks, will be a list of the states that border it. An end-of-line indicates the last adjacent state. In ~cs110/hw4/usa48 is an adjacency list of the lower 48 states of the United States. Other maps may be provided to you, and we may test your program on whatever input we like.

In order to help us verify the correctness of your output, let the output consist of an alphabetized, newline-separated list of state-name, blank(s), color. Specify the color using one of r, w, b or G. Also indicate the total number of gold-colored states in your solution.

To turn in

Turn in softcopy only. Call your program 4color. Have it read from standard input and write to standard output. Include a softcopy writeup. Call it writeup. Make it an ordinary text file. Your writeup must carefully explain how you solved this problem. Your solution should be as efficient as you can make it.

Additional Graphs to Color

Here are some additional graphs you should be able to color. Number of vertices ranges from 13 to nearly 500.

Contest

We will again have a contest (with a magnificent prize). Same rules as before: fastest DEC execution wins. Bring in your listing on the last day of class.