Supplemental Graph Class Instructions


The Graph class Graph.java as given to you, has a constructor that takes the input file name, and the following methods: 

Enhancements you are to  make to above class definition

Methods you are to add to the Graph class

Add the following private new methods to the Graph class.
  1. private boolean hasEdge( int src, int dest ) // T/F edge here ?
  2. private int inDegree( int node )                  // in degree of single node
  3. private int outDegree( int node )                // out degree of single node
  4. private int degree( int node )                     // degree of a single node (= in+out)
Then to add the following public new methods to the Graph class. A word about efficiency and OOP:    I will be deducting points (small penalty) if you are grossly inefficient in how you write your methods. I will also deduct (a bit more of a penalty for this ) if you write code to do something that could have been done using the member functions already given to you.  Think about every calculation you do and ask: "Is there something already written for me that will do this?" Being able to recognize and use existing code to do a task is a fundamental skill. I will continue to place a premium on in.

Don't store results of previous computations in arrays or data structures - just call the private single node degree methods in a loop to compute your public mins and maxes etc.


Write yor private hasEdge() inDegree() outDegree() and degree() methods first and test them first, before writing the public methods minDegrees and maxDegrees etc.