Assignment 5 (150 Points) - Due Wednesday, December 07, 11:59PM

Announcements and Clarification

December 01: For testing your assignment, you can use the graffinator.tgz project to create random graphs that mostly adhere to the retired file format. It is also advises that you test your program on invalid graph formats including but not limited to empty files, random text files, invalid vertex IDs, negative edge weights, negative vertex IDs. You may also want to test file that have contain no edge.

November 27: The example graph input file example.dag.txt has been updated to correctly match the project description.

Graffin: Shortest Path Finder

Create an graffin program capable of determining the shortest path between all pairs of hub vertices within a directed acyclic graph with non-negative edge weights.

Commandline Arguments

Your program must be capable of utilizing a commandline argument to specify the input graph file.

graffin graphFile

Graph Input File

The graph input file will specify the directed acyclic graph structure using the following format:

  1. Number of Vertices: The first nonempty line in the graph input file will specify the number of vertices within the graph using the following format in which the number of vertices in the graph will be specified following the Vertices::
    Vertices: 10
    Each vertex with the graph will be identified by an integer ID starting with an ID of 0. Given a graph with N vertices, your program should create N vertices with your graph data structure with unique ID of 0 to N-1. These IDs will also be used to identify the hub vertices and edges with the graph input file.
    Your program should verify the correctness of the specified graph input file and report any errors within the input file. However, you can assume the provided graph will be acyclic. In other words, your program does not need to check to verify that the graph is acyclic before calculating the shortest paths.
  2. Hub Vertices: At least two vertices within the directed acyclic graph should be identified as hub vertices. The first nonempty line following the specification of the number of vertices will define which vertices are hub vertices. A list of whitespace delimited vertex IDs will be provided following Hubs: as in the following example:
    Hubs: 0 6 9
    Your program should ensure that at least two valid vertex IDs have been specified for the hub vertices.
  3. Edges: Following the hub vertex specification, the edges between vertices within the graph will begin following the line containing Edges:. Weighted edges between vertices will be specified one per line using the following format, in which u is the start vertex, v is the end vertex, and w is the edge weight.
    u -> v : w
    All tokens (u, v, ->, :, w) will be whitespace delimited. Empty lines and lines containing only whitespace should be ignored.
    The following provides an examples of a valid edge specification:
    Edges:
    1 -> 2 : 1
    1 -> 3 : 1
    1 -> 4 : 13
    1 -> 9 : 12

    2 -> 9 : 3

    3 -> 5 : 6
    3 -> 6 : 1

    5 -> 7 : 14

    6 -> 2 : 42

    7 -> 6 : 1

Your program should ensure all edges contain valid vertex IDs and utilize non-negative weights.

Shortest Paths

The graffin program should report the length of all shortest paths from a hub vertex through non-hub vertices to another hub vertex, where the length of a path is sum of all weights for each edge within the path. In other words, your program should find the shortest path between two hub vertices u and v such that all vertices along the path from u to v do not contain any other hub vertices.

Your program should report the lengths of the all shortest paths between hub vertices in order of the vertex IDs using the following format, where u is the starting hub vertex, v is the ending hub vertex, and l is the length of the path:
<u, ..., v> : l
The path itself does not need to be reported, and , ..., should be utilized as a generic indication of the path.
If no path between two hub vertices is found, your program should report the path as Infinity, as in the following example:
<0, ..., 1> : Infinity
The following provides an example output for the graph specification file: example.dag.txt:
<0, ..., 6> : Infinity
<0, ..., 9> : 4
<6, ..., 0> : Infinity
<6, ..., 9> : 45
<9, ..., 0> : Infinity
<9, ..., 6> : Infinity

Extra Credit: Path Reporting (5%)

You may receive up to 5% extra credit if your program not only reports the shortest path length but also reports the entire path itself using the following format, where v0, v1, ..., VN-1, vN is the sequence of vertices in order of traversal, from the starting hub vertex v0 to the ending hub vertex vN, and l is the length of the path:

<v0, v1, ... , vN-1, vN> : l

Extra Credit: C++ Implementation (5%)

You may receive up to 5% extra credit if you utilize C++ and the Standard Template Library to implement the assignment. The receive the full extra credit you must implement your Vertex and Edge data structures using C++ classes with proper object oriented abstractions. You must also utilizes C++ library for all file IO and data structures (i.e. lists, stacks, queues, trees, etc.).

Assignment 5 Restrictions

  1. Instructor/TA Communication for Assignment 5: The instructor and TA will only answer questions regarding Assignment 5 until Monday, December 04.
  2. Late Submission: Assignment 5 may be submitted late with no penalty until Friday, December 09, 11:59PM. No submissions will be accepted beyond this date.

Template Code Project

graffin.tgz