EECS 360 - Machine Problem 5

Graphs

Due: 11:59 pm on Thursday 11/16/2000

For this assignment you are allowed to work with one other classmate in your section. Each group will submit only one homework. Be sure to include the names and EECS User IDs of both students in the header of every every source code file. Your program is also to output the names and EECS User IDs of both students when the program first starts executing. Note: Groups cannot include more than two students. Students are not required (but are encouraged) to work with another student.

This assignment will have you create and maintain a directed graph. You are to use an adjacency matrix data structure similar to what is discussed on page 284 in the Weiss text to store your graph. The graph will have twenty vertices, numbered 1 through 20.

The program is to be interactive.  The commands will be similar to what was used in MP3and MP4.  We will implement the following operations:

a V1 V2
Add the directed edge from vertex V1 to vertex V2. Give an error message if V1 and V2 are the same, or if the edge already exists.

d V1 V2
Delete the directed edge from vertex V1 to vertex V2. Give an error message if the edge does not exist.

r V
Remove the directed edges that use vertex V as either in out-going vertex or the in-coming vertex.

l V
Print the adjacency list for vertex V. If V is zero, print the adjacency list for all twenty vertices.

t V
Print the transitive closure for vertex V. If V is zero, print the transitive closure for all twenty vertices.

o V
List all out-going edges for vertex V. If V is zero, list the out-going edges for all twenty vertices. Note: this command is exactly the same as the l command. So, have both options perform the same operation.

i V
List all in-coming edges for vertex V. If V is zero, list the in-coming edges for all twenty vertices.

u
List all vertices that are used (have either an out-going edge or an in-coming edge). Each vertex should only be listed once.

c
Clear all of the edges from the graph.

q
Quit the program. Give an appropriate good-bye message upon completion of the program

An error message is to be printed and the operation ignored if the value given for a vertex falls outside of the valid range of inputs. All error messages must be descriptive and self explanatory.
  The input for the program will be given through standard input. Each line of input will have one and only one operation. Each operation will fit on one line of input. You may assume that each line is no more than 100 characters long. The first non-white space character will be the character for the operation. If an unknown character is given, print out an error message such as Operation X is not known and ignore the rest of the the input line. White space characters are the space an tab characters. 

Since this program is to be interactive, your program is to prompt the user for each command.

General Comments

For ten (10) points extra credit, implement your program using an adjacency list data structure insted of the adjacency matrix data structure. See page 285 of the Wiess text for discussion of the adjacency list data structure.


Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.

The work you turn in must be 100% done by your own group. You are not allowed to share code with any other groups (inside this class or not). You may discuss the project with other groups; however, you may not show any code you write to another group nor may you look at any other group's written code.

You are to submit this project using the EECS Department's UNIX machine's turnin command. The project name for this assignment is mp5. Be sure to submit all source code and header files and makefile. Failure to turnin all required pieces will result in a lower grade for the assignment. The turnin command for this assignment is:

     turnin -c eecs360a -p mp5 <file list>
where <file list> is the names of all files that you will submit for this program. You can use the turnin command multiple times; however, ever time you must submit all files needed for the program. To see which files you have submitted to turnin use the -v option with the turnin command as follows:
     turnin -c eecs360a -p mp5 -v