Saint Louis University 
Computer Science 314

Dept. of Math & Computer Science 
Topic: Shortest Path Algorithms
Related Reading: Ch. 23, 24
Due:
Monday, 5 November 2012, 11:59pm
This will be a programming project.
For this assignment, you may work in pairs.
Please make sure you adhere to the policies on academic integrity in this regard.
For this homework, we will consider a recent programming programming contest problem (click the link for the problem statement).
Your goal is to develop source code that solves this problem. You may use C++, Java, or Python as your programming language. To be successful, your program must produce precisely the correct output for each test set, as described in the problem statement.
The original description of the geometry and the various witnesses is
just window dressing for what should boil down to a series of
difference constraints of the form
Once you have the various different constraints, the original data is no longer needed. Section 24.4 of CLRS discusses an approach for analyzing a set of difference constraints using a shortestpath computation on a graph model that is constructed from the constraints. In that section of the book, the goal is simply to find a consistent set of values for the variables, assuming one exists. The solution is to introduce one artificial source vertex into the graph and then to compute shortest path distances to all other vertices from that source; if a negativeweight cycle is detected, the set of constraints are inconsistent.
This contest problem goes a step further. When it is possible to satisfy the constraints, you must further determine whether there is a unique ordering of firing times that satisfies a constraint, or whether there are two or more such orderings. In order to solve this problem, we suggest that you instead compute the allpairs shortest path distances in the associated graph. (There is need for introducing an artifical source vertex.)
Our proposed algorithm is as follows:
Otherwise, the contraints are solvable, and we must determine
a proper ordering or detect that the order is not welldefined.
To do this, we consider a new directed, unweighted graph G'
that has a directed edge
There is a onetoone correspondance between valid orderings of the original firing times and topological orderings in the graph G'. To compute a topological order while also checking if it is unique, we recommend an alternative algorithm described in Exercise 22.45.
We have an automated system that will execute your program on the judge's official data sets and compare your results to the expected output. Your program must adhere to the following conventions:
When you are ready to test your program, run the following command on turing:
/Public/goldwasser/314/judge <sourcecode>(where sourcecode is appropriately G.cpp, G.java, or G.py). You are welcome to run this test as many times as you'd like.
Although in a real programming contest, students are only shown the limited input and output examples in the printed material, we will provide you with the complete set of judge's tests that were used on the contest (and which are being used by our automated judging utility). You are free to use these examples in order to trace problems that are arising in your program.
In fact, the above judging utility simply runs your program, stores the output, and compares the actual output to the expected output.Although you are welcome to use the online judging utility to see if your program is correct, you must formally submit your source code through the course web page. If you are working as a pair, only one of you needs to submit the program, but make sure that comments at the beginning of the source code credit both authors.
As with other homeworks, we will grade this out of 100 points.
70 of those 100 points will be based purely on the correctness of your
program on the judge's data. However, rather than an
The final 30 points will be based upon a subjective evaluation of your source code, including its organization, legibility, and documentation.