CS333 Lab 1: Distributed Minimum Spanning Trees

Assigned: Tuesday, September 24
Due: Tuesday, October 8

Goals:

By the end of this lab, you should...

Before starting:

Review the Gallagher-Humblet-Spira minimum spanning tree algorthm described in class on September 12 and 17. For your convenience, the pseudocode presented on September 17 is linked from the examples page.

Study the file Message.txt that defines the message type that you will use. These messages will be serialized for communication across ObjectInputStreams and ObjectOutputStreams. On October 8, the class will go to the lab and you will run your program as one node in a large distributed computation. Therefore, avoid making changes to the message file so your program will be able to communicate with the solutions developed by other students. (You have also been provided with a Message.class file that everyone will use. Do not recompile the Message source code. (The source file is named "Message.txt" instead of "Message.java" to help prevent recompilation.)

Study the file MSTviewer.java that will be the communication server for this lab. Note that all messages will be sent through the server to be forwarded to other nodes in the computation. In "real life," the nodes would send their messages directly to each other, but having the server allows us to see the communication pattern, which is useful for both understanding and debugging the algorithm implementation.

Download this zip file that contains the files described above.

Collaboration: In general in CS333, collaboration is encouraged without restriction, provided that you credit sources. However, for this lab, you can discuss anything with anyone, but you should write your own code. The reason for this is that part of the experience is seeing what it's like to get different versions of the software to work together. (If you all write the same code, it kind of defeats the purpose!)


Part I. Setting Up

Before going too far, it's a good idea to create the skeleton of your MST code to make sure you can connect with the server. The server expects you to connect at port 12345. For now, just run the server and your MST nodes on the same machine, using "localhost" as the IP address in the Socket constructor.

The server expects you to send a REGISTRATION message with your name as the serverData. After you click the "start" button, the server will reply to each node with a REGISTRATION message that contains the node's unique identifier (UID) as the destination, and a TreeMap as the serverData. The TreeMap provides information about the incident edges to that node in the graph. In particular, it maps Integer objects (edge costs) to other Integer objects (the UID of the other endpoint node of that edge).

Write a class, say MST.java, that connects to the server in its constructor as described above. In your "main" method, write a loop that creates several instances of your MST class in order to populate the graph with nodes. Each will connect with the server. Retrieve the UID and TreeMap, and print their contents to make sure you got them. (Remember to click the "start" button after all the nodes show up in the server window.)


Part II. Implementing the Algorithm

Your main job, of course, is to correctly implement the Gallagher-Humblet-Spira minimum spanning tree algorithm. After the REGISTRATION exchange with the server, your MST node should will go into a loop receiving messages and processing them. I strongly recommend using a separate reactToMessage method that takes a Message as a parameter and contains a switch statement to process it according to message type.

You can use the pseudocode from class to help you get started, but it is not a complete correct implementation. You will need to think about it carefully to make sure that everything works correctly...

Important notes:


Part III. Testing

Careful reasoning is the most important thing, but thorough testing is also key. Here are a few suggestions.


What To Turn In:

On October 8, we will meet in Lopata 401 for live individual and combined demos at the regularly scheduled class time. Bring a printed copy of the code for your MST node to turn in. (Don't print out the message class or the server.) Be sure your name is on it, and that you credit any help you may have received.

Be prepared to make run your code and to make modifications to it during class.


Kenneth J. Goldman (kjg@cs.wustl.edu)