2023 SPRING CS 445 LAB #8:
WRITING THE GRAPH CLASS

Background:

AboutGraphs

The Graph class you will write uses uses a 2D array of int as the backing data structure.

Be sure to read document linked at very bottom of this page.

This assignment was borrowed and converted from C++ to Java as needed by Tim Hoffman with permission from it's original author Mark Stehlik


Here are the given files:


Development Strategy

  1. Finish the loadGraph() method. It is called from the constructor.
  2. Finish the toString() method. It is called from the Tester
  3. Run your Graph class against the TinyTester until everything works right.
  4. Once you are sure the TinyTester produces correct output start running your Graph class against the real GraphTester.java and write/test one method at a time.
  5. WRITE AND TEST METHODS -ONE AT A TIME-

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 private member functions for each of the above and  private method

    boolean hasEdge( int src, int dest)   --   T/F whether there is an edge from src node to dest node

After doing so and testing your implementation, you are to implement the following 7 public methods in your Graph.java file to exercise the 4 private member functions above,

For our input file, graphdata.txt, the correct answers are:

This page explains each method and how to write it: Graph Class