Lab Solutions Week 05 - 17x1 COMP1927

Objectives

Assessment

Deadline: 11:59pm Wednesday 18th January 2017

Total Marks: 3

Related Chapters of textbook

Part 5: Chapter 17

Setup

Change into your lab05 directory and run the following command:

cp /home/cs1927/public_html/17x1/week05/labs/files/* .

Note the "." at the end of the command, meaning "into the current directory". If you've done the above correctly, you should find the following files now in the directory:

GRAPH.h

A graph interface file. This should not need to be changed

GRAPH_adjlist.c

A graph implementation using an adjacency list representation. You will need to implement 2 functions in this file

graphClient.c

A graph test program that must be completed to test the graph functions you implement

Task: Implementing functions for a Graph using an Adjacency List representation - 3 marks

You must implement and test the functions

  1.  Graph GRAPHcopy(Graph g); 
  2.  void GRAPHdestroy(Graph g);
  3.  int GRAPHdegree(Graph g, Vertex v); - find the degree of a given vertex 

Each function that is implemented and tested properly is worth 1 mark.

You must test your functions thoroughly by adding code to the graphClient.c program. You must write assert based tests to test your GRAPHcopy code. You should be able to show your tutor using valgrind that your GRAPHdestroy function works properly.

Submission

When you are happy with your work, please show it to your tutor to get it marked. Before you leave your lab, remember to submit your lab via the give command

1927 classrun 17x1 give lab05 GRAPH_adjlist.c graphClient.c