## Create a Class Called Path Graph Implement Shortest Path Algorithm

Create a class called pathGraph and save it in a file called pathGraph.[x] where [x] is the appropriate file extension for your language choice. If you decide to use a language other than Java, Python, C++, or C, you must schedule a time to show me your running code. A pathGraph is an undirected, weighted graph with positive weights. The pathGraph should have an instance variable containing the weighted adjacency matrix and any other instance variables you feel it needs.

Your class should have the following methods:

- constructor – Receives a file name, as a string, of a file containing the weighted adjacency matrix. The first line of the file contains n the number of vertices, indexed from 0 to n-1. The rest contains the weighted adjacency matrix with weights between each edge or -1 if the edge does not exist. You do not have to store the nonexistent edges as -1, but, whatever way you store them, you will have to be clever about your nonexistent edges for each algorithm, i.e., you’ll have to be careful whenever you use your weighted adjacency matrix.
- getEdge(int i, int k) – Returns the length of the edge between i and k or -1 if it does not exist. getSize() – Returns the number of vertices in the graph.
- floyd() – Uses the Floyd-Warshall algorithm and returns D, the matrix containing the lengths of the shortest paths between all vertices in the graph. Make the necessary changes to the algorithm to account for your storage of nonexistent edges.
- dijkstra(int x) – Uses Dijksta’s Algorithm and returns P, an array containing the prior vertex on the shortest path from x to i for each vertex i in the graph, i.e., P[i] = y, then the shortest path from x to i ends in the edge (y,i). Make the necessary changes to the algorithm to account for your storage of nonexistent edges (hint: you may have to separate vertices you are no longer considering and vertices whose known shortest path is currentlyinfinity, plus consider how you are storing your nonexistent edges in the weighted adjacency matrix).
- Bonus: findpath(int x, int y) – returns s, an array containing the shortest path from x to y in the graph. For example, if s = [1;4;2;5;0], then the shortest path from 1 to 0 goes through vertices 4, 2, and 5, in that order.

## STATUS

All methods above should be public, and any extra methods you use should be private (indicate by underscores if you code in Python). Write a tester file that creates pathGraph instances and tests each of your methods with those instances. There is an example with expected results at the end of this project description. Create another graph of your choosing (it’s fine to get ideas from the book/online), use 5-10 vertices, store it appropriately in a text file, and test your code with that graph. Include the results in your write-up as well as an image of what the graph would look like. It’s often easier to start with the

image/design.