EECS 360 - Machine Problem 6

Network Routing

Due: 11:59 pm on Thursday 11/30/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 an information network using an undirected graph. You are to use an adjacency list data structure similar to what is discussed on page 285 in the Weiss text to store your graph. The graph will have twenty vertices, numbered 1 through 20. For ten points extra credit, you can implement your graph using the multi-list structure that was discussed in class instead of the adjacency list data strucure.

For the information network, we will want to make data transfers between two nodes in the network (each node will be a vertex in the graph). Each connection in the network (or edge in the graph) has a maximum amount of data it can transfer at any one time. Thus an edge can only support a specified amount of data transfers at any one time. As each edge in the graph is created, the maximum amount of simultaneous data transfers will need to be given (this is the bandwidth of the edge).

We a data transfer request is made, the shortest path will need to be found between the two node in the graph (we will assume that the connection is bidirectional, so the order of the two nodes does not matter) whose edges have not already been "maxed-out" with data. To keep things simple, we will assume that each data transfer sends one unit of data between the node and the bandwidth of the edge will always be an integer amount greater than one. If no such path exists because these is at least one edge that is maxed-out, the data transfer request must wait until such a path becomes available.

For example, assume there is a connection (i.e. edge) between node 1 and node 2 that has bandwidth of one. Also there is a connection (i.e. edge) between node 1 and node 3 that has bandwidth of three. Also there is a connection (i.e. edge) between node 2 and node 3 that has bandwidth of two. Now:

Your program will have to keep track of the current time, because requests will know when they start and when they end. Again to keep things simple, the time in your program will start with time zero and will increament in integer units of time. You may assume that each unit is a second, but we will NOT be using real time in our programs. When each request is made, it will need to specify the time the request is made and how long the data transfer will take. A request cannot be made for a previous time (i.e. if your program has the "current time" as 23, a request cannot be made at time 15). More information on the time will be given below.

The program is to be interactive.  The commands will be similar to what was used in MP5.  The prompt used in the program must include the current time. We will implement the following operations:

a V1 V2 B
Add the edge from vertex V1 to vertex V2 that has bandwidth of B. Give an error message if V1 and V2 are the same, or if the edge already exists. This command takes no time to complete. (10 pts)

d V1 V2
Delete the directed edge from vertex V1 to vertex V2. Give an error message if the edge does not exist. If the edge is currently in use by one or more data transfers, do not let any more data transfers use this edge and delete the edge as soon as all current data transfers are finished using the edge. This command takes no time to complete. (10 pts)

l V
Print the edges that are adjacent to vertex V. If V is zero, print the adjacency edges for all twenty vertices. As you print each edge, print the maximum bandwidth value and the number of data transfers that are currently using the edge. This command takes no time to complete. (5 pts)

t V
Print the transitive closure for vertex V in two ways. First print the transitive closure without taking into account any current data transfers. Then print the transitive closure taking into account any current data transfers. The difference will occur if an edge used for the first transtive closure is maxed-out with data transfers. If V is zero, print the transitive closure for all twenty vertices. This command takes no time to complete. (10 pts)

r V1 V2 T D
Make a data transfer request from V1 to V2 starting at time T and lasting for D time units. When the request is made, a number is to be given to the data transfer (make the first data transfer number 1, the second number 2, ...). When the data transfer begins, you are to print a message showing the transfer number, the current time, and the path the data transfer uses. If the vertices V1 and V2 are not connected, print an error message and ignore the request. If no path exists because at least one edge has been maxed-out, the request must wait until until enough data transfers complete to "un-max-out" the edges needed for a path. The requests that are waiting should check for a path whenever a data transfer completes or when a new edge is added.

The start time T must be greater or equal to the current time. If the start time T is less than the current time, print out an error message and ignore the request. The duration value D must be greater than or equal to one. If the duration is zero or less, print out an error message and ignore the request. When the start time is greater than the current time, the current time is advanced to the indicated start time. This may result in the completion of other data transfers, which may then cause the starting of waiting data transfer requests. Only after these other data transfer requests have been handled does the current data transfer request get processed. This idea was discussed in class on Friday 11/17/2000.

When a data transfer finishes, a message is to be printed stating the message number and the current time. (15 pts)

p N
You are to print out information for data transfer with number N. If the data transfer with number N has completed or the number N has never been assigned, print a message stating no such data transfer exists. If the data transfer with number N is waiting, print the number and the duration of the data transfer with a message like "waiting for path from V1 to V2", where V1 and V2 are the vertices given in the r command. If the data transfer is currently transfering data, print the number, start time, duration, end time (start time + duration) and path for the data transfer with number N. This command takes no time to complete. (10 pts)

w
List all waiting data transfer requests. The information that should be given is the number of the data transfer request, the duration of the data tranfer and the V1 and V2 values given when the request was made with the r command. This command takes no time to complete. (5 pts)

c T
Advance the current time to the value of T. If the time value T is less than the current time, print an error message and ignore the command. This may result in the completion of data transfers, which may then cause the starting of waiting data transfer requests. This idea was discussed in class on Friday 11/17/2000. (15 pts)

f FILENAME
Read the commands from indicated file with the name of FILENAME. The main purpose of this command is so you don't have to type in all of the commands when testing (and grading) your program. The file(s) used to grade your program will not include the f command. The f command itself does not take any time complete; however, the commands listed in the file may take time to complete. The results of the commands in the file should be identical to the results if the same commands were typed in on the command prompt. If a file with the name of FILENAME does not exist, print an error message and ignore the command. (10 pts)

q
Quit the program. Give an appropriate good-bye message upon completion of the program. (3 pts)

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. (3 pts)

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. This prompt must include the current time.

Sample Program Execution

The following is intended to be a sample program execution. Note this was created and typed by hand. It has been checked for error, but that does not means it is error-free. The items in bold type would have been typed in by the user of the program.
Time: 0> a 1 2 1
Time: 0> a 1 3 3
Time: 0> a 2 3 2
Time: 0> t 1
  Transitive Closure (all edges):       1, 2, 3
  Transitive Closure (available edges): 1, 2, 3
Time: 0> r 1 2 0 2
  Data Transfer #1 started at time 0 on path: (1,2)
Time: 0> r 2 3 0 4
  Data Transfer #2 started at time 0 on path: (2,3)
Time: 0> l 1
  Edge (1,2) Bandwidth: 1, In Use: 1
  Edge (1,3) Bandwidth: 3, In Use: 0
Time: 0> l 2
  Edge (1,2) Bandwidth: 1, In Use: 1
  Edge (2,3) Bandwidth: 2, In Use: 1
Time: 0> t 1
  Transitive Closure (all edges):       1, 2, 3
  Transitive Closure (available edges): 2, 3
Time: 0> r 1 2 0 5
  Data Transfer #3 started at time 0 on path: (1,3),(3,2)
Time: 0> t 1 
  Transitive Closure (all edges):       1, 2, 3
  Transitive Closure (available edges): 3
Time: 0> r 2 3 1 5
  Data Transfer #4, Waiting
Time: 1> r 3 1 1 7
  Data Transfer #5 started at time 1 on path: (1,3)
Time: 1> r 2 3 1 2
  Data Transfer #6, Waiting
Time: 1> r 2 3 1 2
  Data Transfer #7, Waiting
Time: 1> w 
  Data Transfer #4 From 2 to 3 waiting, Duration 5
  Data Transfer #6 From 2 to 3 waiting, Duration 2
  Data Transfer #7 From 2 to 3 waiting, Duration 2
Time: 1> p 1 
  Data Transfer #1, Start time: 0, Duration: 2, End time: 2
    Path: (1,2)
Time: 1> p 4 
  Data Transfer #4 From 2 to 3 waiting, Duration 5
Time: 1> c 4 
  Data Transfer #1 ends at time 2
  Data Transfer #4 started at time 2 on path: (2,1),(1,3)
  Data Transfer #2 ends at time 4
  Data Transfer #6 started at time 4 on path: (2,3)
Time: 4> p 1 
  Data Transfer #1 unknown
Time: 4> p 4 
  Data Transfer #4, Start time: 2, Duration: 5, End time: 7
    Path: (2,1),(1,3)
Time: 4> c 7
  Data Transfer #3 ends at time 5
  Data Transfer #7 started at time 5 on path: (1,3)
  Data Transfer #6 ends at time 6
  Data Transfer #4 ends at time 7
  Data Transfer #7 ends at time 7
Time: 7> c 10
  Data Transfer #5 ends at time 8
Time: 10>

General Comments

In addition to the data structure for the graph, you will need to keep track of all data transfers and waiting data transfer requests. Exactly what form of data structure you use is up to you, but you must write the data structures yourself. You may not use any data structures in a library (like the C++ STL).

Your program must be written in good programming style (4 pts). 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 mp6. 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 mp6 <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 mp6 -v