Background:
Lab 1 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 lab1.zip file from the 15-113 course web site. Save the
zip file to your temp directory and unzip the files. You should see the
following files:
- lab1.mcp
- graph.txt
- graph-adj.cpp
- graph-adj.h
- graph-driver.cpp
- matrix.h
Open the lab1.mcp file and look at the filenames listed inside. lab1.mcp is
a CodeWarrior project file. The project file serves to manage the various
libraries and source files that make up your program. More about this in
Thursday's recitation.
Assignment
The degree of a vertex is the number of edges incident to that
vertex. For a directed graph, we can define the following terms:
- out-degree - the number of edges leaving the vertex
- in-degree - the number of edges entering the vertex
- degree - the number of edges entering and leaving
the vertex
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.cpp to exercise the 3 new member
functions:
- Max Out Degree - the maximal number of edges leaving any
single vertex
- Min Out Degree - the minimal number of edges leaving any
single vertex
- Max In Degree - the maximal number of edges entering any
single vertex
- Min In Degree - the minimal number of edges entering any
single vertex
- Max Degree - the maximal number of edges entering/leaving any
single vertex
- Min Degree - the minimal number of edges entering/leaving any
single vertex
To run your program, open a DOS window, cd into the directory where
you're working and type the following command: 113.exe graph.txt.
For the sample file, graph.txt, the correct answers are
- 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
- lab1.mcp (the project)
- graph-adj.cpp
- graph-adj.h
- graph-driver.cpp
Do not include a copy of the datafile (graph.txt) or the matrix.h file as
neither of these are changed.
Use the Intro Programming
dropoff form to submit your zip file.