Lab Exercises Week 06

Objectives

Assessment

Deadline: 11:59pm Tuesday 26th January 2015

Total Marks: 3

Related Chapters of textbook

Part 5: Chapter 17

Setup

Change into your lab06 directory and run the following command:

cp /home/cs1927/public_html/16x1/labs/lab06/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 1: Implementing functions for a Graph using an Adjacency List representation - 2 marks

You must implement and test the functions

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.

Task 2: Creating test data for assn2 - 1 Mark

You may do this task in pairs.

Create a file with test data for assignment 2 called citiesLarge.data that contains at least 20 vertices.

Create agent files named agentsA.data and agentsB.data files that create situations where the thief gets to the getaway and where the detectives catch the thieves using a given seed and experimenting with the model solution.

Create a file name testCases.txt that documents how to run these test cases and what the result is (Note: you can use any seed you like - I have just used 0 in this example). For example

~cs1927/bin/assn2Model citiesLarge.data agentsA.data 100 0
results in the thief getting to the getaway destination in Hour 7.
~cs1927/bin/assn2Model citiesLarge.data agentsB.data 100 0
results detective 3 catching the thief in destination 6 in Hour 17.

You should also create outut files that cature the exact output of the model solution. These should be named outA.txt and outB.txt. For example you could create them in this way:

~cs1927/bin/assn2Model citiesLarge.data agentsA.data 100 0 > outA.txt
~cs1927/bin/assn2Model citiesLarge.data agentsB.data 100 0 > outB.txt
For this exercises we do not want you to create tests for simple situations where the thief starts in the same location as one of the detectives. In fact, the longer you can make the game run before anyone wins, the better!

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 16x1 give lab06 GRAPH_adjlist.c graphClient.c citiesLarge.data agentsA.data agentsB.data testCases.txt outA.txt outB.txt