Throughout computer science, mathematics, chemistry, sociology, physics, and various other sciences, graphs are widely used. In this project, you will implement a graph, along with several methods that operate on graphs to test graph properties. The last section of the textbook (4.5) will be invaluable for this project.
The primary goals of the project are to:
You will need to build four classes for this project:
In your Graph class, you must provide six additional methods:
Note that both of these methods return Iterable<String> classes (which all java collections are), and this set of strings is the path from s to d (the arguments in both methods).
Note that a DepthFirstSearch is the opposite of BreadthFirstSearch: instead of checking all the neighbors, and then all the neighbor's neighbors, we continue down one path until we can no longer find the node and then backtrack to try a different path.
Use the Graph class to read in the following text file: cast.mpaa.txt, which lists all the movies rated by the MPAA. Fields are separated by '/', begin with the movie name, and are followed by all the actors in the movie.
Note, if you're having problems with the file being too big, you may use cast.06.txt or cast.G.txt. Please add this to your project so that Kav can grade it properly.
For each movie and actor, we will create a vertex. Edges will connect each movie to the list of actors in that movie. Once processed, you will run both BreadthFirstSearch and DepthFirstSearch on your choice of 10 pairs of actors. This will give us a list of nodes connecting each pair. This data will be recorded in a file called 'results.txt' that will be turned in.
You will need to use subversion with your group or solo (remember, groups can be up to 3 people). We will simply check-out your repository at the end of the day that the project is due, so check-in your project frequently and of course when you're done.
Your turn in must include a file called 'results.txt', that lists the breadth-first and depth-first search between 10 pairs of actors. The searches will list all the nodes
You must include comments in your code to explain what you're doing. In your comments, you need to state what the expected running time, in terms of n, will be to call that method.
Your project will be graded on the correctness of your implementation and your understanding of its performance. In particular: