CS127 Final Project

Due 5:00PM Sunday, 3/16/03.

You may talk to other people about your project, and you may help one another, but you should write and hand in your own program. If you get significant help from someone or borrow a small piece of code, acknowledge that help in both your documentation and in comments in the code itself.

What to hand in

By 5:00 Sunday, March 16, submitted via HSP.

Six Degrees of Edsger Dijkstra

There's a game that was once known as the "handshake game" (at least in my family), where you try to make chains from one person to another, where each link is a pair of people who have met each other (shaken hands, at least metaphorically). The example I usually use is a chain from me to Mozart: I met my piano teacher Bernard Weiser, who studied with pianist Carl Friedburg, who took lessons from Clara Schumann, who met Johann Goethe, who met Mozart.

This game became much better known when the movie Six Degrees of Separation was released in 1993, followed by the ridiculous but entertaining 1996 book Six Degrees of Kevin Bacon, which shows how to link all sorts of actors and actresses to Kevin Bacon using linkages of the sort "A was in a movie with B." For example, Marlon Brando is linked to Kevin Bacon: Brando was in The Godfather with Al Pacino, who was in Sea of Love with Ellen Barkin, who was in Diner with Kevin Bacon.

For this project, you are going to write a program to compute linkages of this sort. You will use two files: a handshake file and a query file. The handshake file will consist of lines with three tab-delimited fields, like this:

Jeff Ondich[tab]Bernard Weiser[tab]1
Bernard Weiser[tab]Carl Friedburg[tab]1
Jeff Ondich[tab]Steve Lewis[tab]1
Jeff Ondich[tab]Bill Clinton[tab]3
Steve Lewis[tab]Bill Clinton[tab]1
Jeff Ondich[tab]Fred Brooks[tab]1
Jeff Ondich[tab]Donald Knuth[tab]2
Jeff Ondich[tab]Edsger Dijkstra[tab]3
Jeff Ondich[tab]Maurice Wilkes[tab]3

(Note that by "[tab]", I mean a single tab character, representable in C++ by '\t'.) The idea here is that we'll represent linkages as pairs of names plus an integer marking the quality of the linkage. In this example, 1 means that the people in question have actually met each other, and at least temporarily known each other's names. 2 means that they have spoken, but that at least one of them never knew the other's name. 3 means that they have been within eyesight of one another, in person, but have not spoken. For example, when Bill Clinton gave the Carleton commencement address in 2000, I was in the audience (3), but Steve Lewis actually met and spoke at some length with the President (1). Similarly, I had Turing Award winner Fred Brooks over for dinner at my house (1), I have spoken briefly to Turing Award winner Donald Knuth (2), and I shared a lecture hall (3) and an elevator (3), respectively, with Turing Award winners Edsger Dijkstra and Maurice Wilkes.

The query file will look like this:

Bill Clinton[tab]Jeff Ondich
Jeff Ondich

A line with two names on it (separated by a tab) is asking "display the shortest path from the first name to the second name." So the first line in this example should cause your program to show the path that goes from Bill Clinton to Jeff Ondich via Steve Lewis (for a total path length of 2, which is better than the path from Clinton to me directly via the length-3 connection). A line with one name on it asks you to print all the people in the graph that are accessible via any path from the names person. Technically, then, the second query in this example is asking you to print out the connected component of the graph that contains Jeff Ondich.

The command line syntax for your program will be:

handshake handshake_file [query_file]

If the user types both command-line arguments (that is, the names of a handshake file and a query file), then your program should print out the results of all the queries in the query file. If your program is invoked only with the handshake file argument, then it should print the following information about each connected component of the handshake graph:

Grading Criteria

Advice

Start early, have fun, and keep in touch.





Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057, (507) 646-4364, jondich@carleton.edu