Cmpt 225

Simon Fraser University
School of Computing Science

Cmpt 225 - Lab #5

Graphs


Objectives

Our objective in this lab is implement a simple graph ADT to define a directed graph clas, then use Java inheritance to define an undirected graph.

Problem Statement and Specific Requirements

You must implement the interface GraphInterface as follows:
  1. Define a class DirectedGraph that implements the interface, using an adjacency matrix of boolean values. The DirectedGraph class must have only one constructor DirectedGraph(int n), which should create a graph with n vertices that initially has no edges.
  2. Use Java inheritance to define UndirectedGraph by extending your DirectedGraph, overriding whichever methods you need to override.
  3. Write a class TestGraph with a main method in which you define a graph of size 4 and then add all possible edges.

Suggestions

Using appropriate data fields with the right access modifiers makes this task straightforward.