CS 314 - Specification 12 - Graphs (Down with the BCS!)

Programming Assignment 12 - Individual Assignment. You must complete this assignment on your own. You may not acquire from any source (e.g.  another student or an internet site) a partial or complete solution to a problem or project that has been assigned. You may not show another student your solution to an assignment. You may not have another person (current student, former student, tutor, friend, anyone) “walk you through” how to solve an assignment. You may get help from the instructional staff. You may discuss general ideas and approaches with other students but you may not develop code together. Review the class policy on collaboration from the syllabus.

The purposes of this assignment are:

  1. implement graph algorithms
  2. use graphs to rank college football teams based on the games from a single season

Description: In this assignment you will implement two instance methods for a graph data structure and one method in a client of the graph that evaluates properties of the graph.

When finished turn in your Graph.java, FootballRanker.java, and GraphAndRankTester.java files.

Provided Files:

  File Responsibility
Documentation Documentation for the provided classes. Provided by me.
Implementation Graph.java. A class that implements a Graph data structure. Complete the two required methods. You may alter and use the nested classes as you wish. Provided by me and you.
Implementation

FootballRanker.java. A class that ranks football teams based on their performance using the Graph class. Each team is a vertex. A directed edge exists between team A and B if team A beat team B. The weight of the edge is determined by the score of the game between teams A and B. The closer the score the LARGER the weight. Complete the required method.

Provided by me and you.
Implementation GraphAndRankTester.java  A class that runs tests on the Graph and FootballRanker classes. Add more tests to the class for the Graph class and the FootballRanker class.

Answer the question at the top of GraphAndRankTester.java.

Provided by me and you.
Provided Files FootballRecord.java A simple class for modeling the record of a football team.

AllPathsInfo.java A class with information about all paths from a given vertex in a Graph to other vertices in the Graph.

These classes are used by Graph.java and FootballRanker.java

Provided by me. Do not alter.
Data Files 2008ap_poll.txt and div12008.txt - The data files that generate the sample output. The div12008.txt file contains the results of all division I college football games from 2008 and 2008ap_poll.txt file contains the final division I Associated Press rankings for 2008.

2005ap_poll.txt and div12005.txt - Another set of data files. Run your program with these data files and compare results on the class discussion group.

Finally here all games from 2008, (games08.txt) not just the division 1 teams. Try your program on this file and compare the results to those with just the division 1 teams. Some surprises occur. The question in GraphAndRankTester ask how to adjust results when all teams are included.

Provided by me. Do not alter.
Sample Output Sample output. Based on 2008 data. Your output must match this exactly. Provided my me.
All Files A12.jar All files in a jar. (If you would rather not download all of the files above separately.) Provided by me.
Submission Graph.java, FootballRanker.java, and GraphAndRankTester.java files. Provided by you..

Background: As of fall 2013, Division 1 college football is one of the few college sports where the champion is not determined by a tournament run by the NCAA. Instead the BCS uses various polls and surveys are used to determine the "best" two teams who then play each other in the final game of the season. The ranking algorithm the BCS uses consists of two human surveys PLUS six algorithms carried out by computers. (Note, the algorithms used by the BCS are not allowed to take into account the score of games only whether a team won or lost a game.)

In this assignment you will complete a Graph class and a FootballRanker class that determines the "best" team based on the graph formed by the teams and the games they played. (The BCS is going to a four game playoff in the fall 2014 season.)

Your program shall rank teams three ways and compare the results to the Associated Press end of season poll. The three ranking for the assignment algorithms are:

  1. Rank each team by calculating the number of other teams they are connected to and the average shortest UNWEIGHTED paths to those connected teams. Determine the average UNWEIGHTED path length by dividing the total sum of all shortest, unweighted path lengths (number of edges in path) by the number of vertices (teams) connected.
  2. Rank each team by calculating the number of other teams they are connected to and the average shortest WEIGHTED path to those connected teams. Determine the average WEIGHTED path length by dividing the total sum of all shortest, weighted path lengths by the number of vertices (teams) connected.
  3. Rank each team using the result from method 2 and then dividing the average weighted path length by the team's win / loss percentage.

Most of the program has been completed already. There are three methods you must complete are:

  1. Complete the instance method dijkstra in the Graph class. This method finds the shortest weighted path from the given start vertex to all other vertices in the graph using Dijktsra's Shortest Weighted Path Algorithm. Read the method documentation thoroughly to understand all the requirements of the method. Recall the class slides contain the pseudocode for this algorithm.
     
  2. Complete the instance method findAllPaths in the Graph class. This method updates each vertex in the Graph so that each vertex stores the number of other vertices it is connected to. (In the assignment this is also referred to as the number of paths from the vertex.) The method also finds the sum of all the shortest weighted and unweighted paths from the vertex to every other vertex it connects to. If the boolean parameter named weighted is false these values will equal each other.

    Each Vertex object has instance variables to store this data. The method must call the findUnweightedShortestPath or dijkstra methods as appropriate. The Vertex class, the nested Path class, and  the getPath(String) method are useful for completing and testing this method. A lot of the support code is already done for you. You must determine how to use the existing code.

    The method also stores the "longest shortest" path in the Graph. Because the method must find the shortest path between all pairs of vertices relying on the given findUnweightedShortestPaths method or the dijkstra you complete based on the value of the parameter weighted, we can keep track of the longest of the shortest paths we find. The length of the paths shall be based on their weighted cost. For the findUnweightedShortestPaths this is the same as the number of edges in the path. Use the getPath method to create a Path object for the longest (highest cost) path you find as you search the shortest paths. Use the instance variable named longest to refer to this Path object.
     
  3. Complete the printRootMeanSquareError method in the FootballRanker class. The FootballRanker class computes rankings for teams based on the three approaches described above. This method relies on the findAllPaths method which in turn relies on the dijkstra method, so you must complete those two methods before this one will work properly.  The  printRootMeanSquareError  method in the FootballRanker compares the computed rankings from findAllPaths with the end of season poll from the Associated Press. The AP's ranks are stored in list parameter sent to this method (position in list is equivalent to rank when using zero based indexing) and the graph ranks are in the TreeSet. Iterate through the AP ranks and determine the root mean square error between the AP ranks and the calculated ranks. The root mean square error is determine by taking the difference between the AP rank and the predicted rank, squaring the difference, adding all of these squared differences together, dividing by the number of teams, and taking the square root. The mathematical formula:



    where, n is the number of teams, x1 is the AP rank for the ith ranked team, x2 is the predicted rank for that team based on our graph calculations, and n is the number of teams. If a team is ranked in the AP poll, but not in our predictions assign it a rank equal to one more than the total number of teams in the graph predictions. (The FootballRanker cuts some teams from the predictions if they do not have enough direct or transitive wins. (wins based on connections in the graph)). The method prints out the data as shown in the sample output and returns the root mean square error rounded to the nearest tenth.

You may find the Java DecimalFormat class and String.format method useful in formatting output and return values.

Your output must match the example output exactly

Your class must pass the tests in GraphAndRankTest class.

Add your own tests to the GraphAndRankTest  class.

Answer the question at the top of the GraphAndRankTest  class. (Put some thought into this.)


Checklist: Did you remember to: