lab5: Working with the Graph Class

Due Date: Wednesday October 31, 23:59.

Background: Lab5 should be a refresher on implementing member functions and then using those member functions in a client program to perform certain actions. Once you're done, you will use the Intro-CS Assignment Dropoff form to hand in your finished program.

What You'll Need :Download the lab5.zip file from the 15-111 course web site. Save the zip file to your temp directory and unzip the files. You should see the following files:

Open the lab5.mcp file and look at the filenames listed inside. lab5.mcp is a CodeWarrior project file. The project file serves to manage the various libraries and source files that make up your program.

Assignment

Complete all unfinished methods in the Graph class. Then complete the following methods. The degree of a vertex is the number of edges incident to that vertex. For a directed graph, we can define the following terms:

You are to declare and implement member functions for each of the above. After doing so and testing your implementation, you are to implement the following client functions in graph-driver.java to exercise the 3 new member functions:

To run your program, press F5. The output must be similar to the following.

Sample output

The graph is

0     ==>   (1,10)   ,  (6,2)

1     ==>   (2, 31)

2     ==>   (3, 5)

3     ==>   (4, 11)

4     ==>   (5,9) , ( 0, 13)

5     ==>    (1,25)

6     ==>    (7, 15), (8, 6), (9, 22)

7     ==>    (9, 12)

8    ==>     null

9    ==>     (8, 1)

Max Out Degree - 3

Min Out Degree - 0

Max In Degree - 2

Min In Degree - 1

Max Degree - 4

Min Degree - 2

Handing in your Solution

Your solution should be in the form of a .zip file. When we grade your solution we will unzip the folder and execute the project.

Your Solution zip file must contain (only) the following files

  1. project.mcp (the project)
  2. graph.java
  3. driver.java

Do not include a copy of the datafile (graph.txt).