In this program, you will be maintaining information about a number of transportation routes between various cities. The primary purpose of this program will be to determine a path that get a person from one city to another with the fewest amount of transfers between routes. A transfer is when a person is riding along one route and switches to another route. Ideally a person would like to make zero transfers, i.e. find a route that contains both cities. We will not care about any other factors of the routes (i.e. cost, distance, travel time, etc.). The only criteria used will be the number of transfers.
This program is basically a graph problem that uses a breadth-first search to solve the problem. You may wish to refer to a data structures text to get ideas on how your data structure should be set up. You are to write a program that will compile using the g++ compiler (i.e. in either C or C++). You will be required to submit a makefile with your program that will compile your program and create an executable called mp1.
The program is to use text input to get commands from standard input or a file. Each command will be given on its own line in the input and can be in either upper or lower case. The command will be the first non-white space character on the line. If the first non-white space character is not a command some error message should be produced. For this program, you may assume that the white-space characters are the space and tab characters. You may also assume that each line is at most 100 characters long. Each command (except for the # command) is to produce a message stating the command occurred. The commands are:
Here are a list of data files that we created. These do NOT test all possible input to your program. So you will have to create your own tests for this. Also, these files are not the only ones that will be used when grading your program.
Lexicographical order is normal sorting order used for strings. All names will not be case sensitive, thus the city name of "Chicago" is the same as "chicago" or "CHICAGO" or "ChIcAgO"; however, when storing names in your program the first letter of each word must be in upper case, while all remaining letters in the name are in lower case. Thus the name given as "nEw yoRK" would be stored as "New York". Your program is responsible for any neeeded case conversions.
Also all names are to stored with no leading or trailing white space characters (white space characters are blanks/spaces, horizontal tabs, vertical tabs and newline characters - in this program, since all names will be given on a single line, only the blank/space and horizontal tabs will be considered as white space) and only a single space character is used to separate words. Thus if a name has leading white space, multiple white space between words or trailing white space, your program will have to modify the name to deal with these.
When storing a name in your program, you must allocate only an much memory as the name requires. Therefore the city name of "Chicago" must not be stored in a character array of 100 characters. You may use null terminated strings, thus storing "Chicago" in 8 characters. Since you will have to look up both route and city names, you must use some fast look-up algorithm like a hash table to quickly find the name's location in the graph.
This program will NOT require the use of multiple source code files and separate compilation. This will be manditory for all future assignments, so you may wish to try it out here. The division of the subroutines between the multiple source code files must be logical. One suggestion would be to have the graph rountines in one source code file and the command interface commands in another source code file. This suggestion only specifies two source code files, you may wish to have more that two source code files for your program. Note: a "source code file" is not the same as a "header file". Source code files will have a file extension of .c (or .cpp, .C, .CC, etc.), while a header file will have a file extension of .h. To perform separate compilation, your makefile must separately compile the source code files into ".o" files and then link the ".o" files together. Using a #include statement with a source code file (a .c file) will NOT satisfy a requirement of separate compilation.
In addition to using and submitting a makefile, this program will also require a 1-2 page write up of the data structures used in the program and the logical division of your program into multiple source code files (i.e. which routines are where). Remember that this write-up is to be written in ASCII format and is to be electronically turned in with your program. The name of this file should be "readme.txt". Also recall that your program will be given to another student to write a critique. Therefore, it is suggested that you do not include your Social Security Number in your program. Instead use your name and your CS User ID to identify yourself.
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% your own. You are not allowed to share code with any other person (inside this class or not). You may discuss the project with other persons; however, you may not show any code you write to another person nor may you look at any other person's written code.
You are to submit this project using the CS Department's UNIX machine's turnin command. The project name for this assignment is mp1. Be sure to submit all source code, header files, makefile as well as your program description. Failure to turnin all required pieces will result in a lower grade for the assignment.