Homework 7 - Weighted Directed Graphs

Extra Credit (no late assignments accepted)
Due: Monday, November 26, 2007 at 11:00am (before the final)

For this homework assignment, modify the directed graph code given in Figure 16.1 (Digraph.h) in the book. The modifications are as follows:

Menu Program

Write the following menu program to test your directed graph code.
     Welcome to the Directed Graph menu
----------------------------------------------
1. Read in a directed graph from a file
2. Do a depth-first search 
3. Do a breadth-first search
4. Compute the shortest path between two nodes
5. Print the directed graph

0. Exit
----------------------------------------------
For option 1, prompt the user for a filename, open the file and then call the read function on that file.

For options 2 and 3, prompt the user for the index of the starting node and then perform the search from that starting node. If the whole graph cannot be searched from that node, select an unprocessed node at random and repeat the search until all the nodes have been processed.

For option 4, prompt the user for the index of the starting node and the index of the destination node. Call the shortest path function with these two nodes. Print out the shortest path if the destination can be reached or "destination not reachable" if it cannot.

For option 5, call the display function.