Programming 4
Due Date: Dec. 7th
Assignment
In this assignment, you are tasked with implementing the graph ADT using an adjacency list implementation. As usual, there will be a code portion and a report portion to this assignment.
In addition to the regular portions, you are allowed to do this assignment in pairs. If you choose to have a partner, they must be from the same lab section (unless otherwise approved), and you will be required to do more implementation/reporting.
Code
At a minimum, you must implement the following for your graph:
- Core ADT as found in the book. This means you need to allow for insertion
and removal of vertices and edges, implement all vertex and edge functions.
However, the design of the functions is up to you. Name your graph class "graph"
and place it in a file named "graph.h". Remember to create a test application so
you know your graph compiles and runs correctly.
Basic interface requirements are found here and described
below.
- Graph takes two template parameters for vertex object and edge object types and should contain internal classes for vertex and edge.
- Vertices are referred to by a global vertex descriptor (size_t). Edges are referred to by edge descriptors (pair<size_t, size_t>).
- Typedefs should define descriptors, vertex iterators, edge iterators, and adjacency edge iterators.
- Basic accessors provided to properties, descriptors, begin/end iterators, and finding vertices/edges based on descriptors.
- Basic modifiers should be provided for inserting and removing vertices and edges.
- Input/Output operators for your graph class. Use the following as
file specifications:
Example file:
5 4
D
E
N
N
Y
0 1 40
3 4 23
1 0 40
4 3 23
Specification
num_vertices num_edges
vertex_0
vertex_1
...
vertex_n
edge_0
edge_1
...
edge_m
Note edges are formed as
v_i v_j weight
. Here is a larger example file for agraph<int, int>
. - Breadth-first Search Algorithm which labels the vertices and edges as discussed in class and stores extra pointer information for the BFS tree. Interface for the BFS function can be found in this algorithms file.
- Proper documentation of all classes and methods in Doxygen style comments
(as all of my code examples for you have done). Set up a Doxygen file (again use
mine as an example) to create automatic webpages (to be turned in with your
assignment). These can be created on
sun.cs.tamu.edu
. - If you decide to work with a partner you must also implement one of the MST or SSSP algorithms for your graph. Interfaces for these functions can be found in this algorithms file.
Report
For each algorithm you implement, test performance of your graph on a planar mesh (each vertex has degree 4 essentially, it is basically a grid), a complete graph, and a random connected graph (start with a connected line of vertices, then add random edges). After doing base performance measures also determine big-oh constants for the algorithm for mesh-input. The report should include the following sections:
- Introduction
- Implementation details - Discuss design decisions of the graph
- Theoretical Analysis - Discuss complexity of graph operations and algorithms
- Experimental Analysis - include setup, results, big-oh constants, and discussion of results
- Conclusion
Bonus
Each extra algorithm and graph implementation that is implemented and analyzed can receive bonus points. Note if you are working in pairs, bonus points will be split between partners. Interfaces for such extra functions should follow this algorithms file.
Competition
I am curious which person/team can create the best implementation of a graph. Those wishing to participate in a competition can submit their graph.h and graph_algorithms.h files the night before the due date (emailed to me). The lecture period of, I will run a live timing test to see which team generates the best graph implementation. The winner will receive a special prize!
- The graph.h must conform to the specifications given and must compile with my test code in order to be able to participate in the competition.
- I will be performing random graph operations and algorithms (including edge/vertex deletion).
- Failure to complete the test/segfault will result in a disqualification.
- Top times (so far)
Grading Rubric
Each assignment composes 4% of your final grade. Each assignment will be graded out of 100 possible points. Please document code appropriately and use a standard programming style (i.e., name things nicely and effectively).
Turn in instructions - there are two separate items to turn in in two separate places (total of 4 things). Printed items are due before class and online items are due at 11:59pm the day of.
-
Printed
- Project code - print out edited files, i.e., where you actually wrote code (e.g., .h files and timing code). Staple these together and put a cover page on this code packet.
- Project report - print out the report with its own cover page.
-
Online
- Project code - turn in a complete zip file of all code/documentation/makefiles (.h and .cpp files) to eCampus.
- Turn in a PDF of the report to eCampus.
All assignments must be turned in with a signed coverpage. If no coverpage is provided, the assignment will not be graded.
If there are any discrepencies in grades please see Jory Denny during his office hours (not the TA or Grader).