CS 112
Final Project
Due: Thursday, Dec. 14 by 8:00 a.m.
5-10 Minute In-class presentation on Th Dec 14, 8:00-10:20.


The final project asks for the implementation in C++ of a comprehesive set of graph connectivity functions. You will "present" the project to me (Ileana) in the last day of classes. I.e. you will run the program for me and show me its various features, as well as be ready to answer any questions I might have regarding the way it was done.

The program builds on Homework 10 by reusing (and perhaps enhancing) the following features: To get a minimum passing grade on the project (C), you should submit at least a complete solution to Hw10 (fully working and including typescript showing thorough testing). Building on this, and for increased final project grades, you will include new features. Please add them incrementally, test them thoroughly and be ready to submit the highest level version you have completed, rather than attempting a complete program that does not work at all. Remember that among the skills I am testing you on with the final project are your improved software engineering abilities, including the development and testing of software, code reuse, documentation and readability for easy maintenance.

The new features that you will have to implement now include:
  1. A function for performing DFS from a given vertex v. The visited nodes should be printed on the standard output (screen) as they are visited.
  2. A function which returns a list of all the nodes reachable from a given node v.
  3. A function to decide if there exists a path from a given node v to another node u in a directed graph.
  4. A function to decide if there exists a node that cannot be reached from a node v, in a directed graph.
  5. In the main program, add an option to work with undirected graphs, not just directed graphs. Each time the user adds an edge from vertex a to vertex b, the program automatically adds an edge from b to a. The undirected graph should be implemented as a separate class (called, for instance, UGraph). Although very similar, as a data structure, to the directed case, it will have different functions associated to it.
  6. The menu options should allow the user to work with either directed or undirected graphs.
  7. The UGraph class should contain (besides the constructor, read input, print and functions for adding nodes and edges) at least the following functions:
    1. A function to perform DFS on the graph. Each visited node is printed on the standard output.
    2. A function to return a list of all the nodes reachable from a given node in the graph.
    3. A function to decide if the undirected graph is connected.
  8. So far, the data you could store in the nodes of a graph was very simple, just two characters. At the top level of complexity for this project, I am asking you to create a template class Graph, which will allow you to store other types of data in a graph node. The main program should allow you to create at least two instances of this template class: one should be the previous class Graph (with 2-characters per node as its associated data), and the second with some other type of data (e.g. an integer id number).
Roughly: a complete solution up to 4 is worth a B, a complete solution up to 7 gives you an A-, and all the 8 points give you an A. "Up to" means "up to and including". "Complete" means everything: it compiles, it works, shows sound programming style, it is thoroughly tested, well documented, readable, nice user-interface, clean typescript, and is submitted in time.

To submit:


Ileana Streinu