Write and document a Java program that solves the problem described above -- that is, given an adjacency-matrix description of a directed edge-weighted graph and a set of vertex sequences on this graph, compute and display for each sequence (1) the summed shortest paths (by summed edge-weight) of the adjacent vertex-pairs in that sequence and (2) the summed shortest path edge-counts of the adjacent vertex-pairs in that sequence. A graph on n vertices is specified as an (n + 1)-line file, where the first line has a single number giving the value of n and the remaining n lines specify an edge-weighted adjacency-matrix such that M[x,y] = z for some positive non-zero integer z means that there is an arc of weight z from x to y and M[x,y] = * means that there is no arc from x to y. For example, the directed edge-weighted graph
is described by file net1.dat, e.g.,
5 1: 0 50 * * 100 2: * 0 75 100 * 3: 200 * 0 50 * 4: 300 * 50 0 250 5: * * * * 0
A vertex-sequence file with n vertex-sequences is specified by an (n + 1)-line file, where the first line specifies the number of vertex-sequences and each of the remaining lines contains a vertex-sequence consisting of some set of positive non-zero integers separated by blanks. One such file relative to the graph above is file route1.dat, e.g.,
10 2 1 1 4 4 2 2 5 3 5 5 2 2 1 4 2 4 2 1 4 4 2 5 1 2 5 1 4
You may assume that all input files are formatted correctly. Examples of several program runs relative to the graph files net1.dat and net2.dat and the vertex-sequence file route1.dat are given in script file out.script.
///////////////////////////////////////////////////////////////// // CS 3711 (Fall 2005), Assignment #5, Question #1 // // Program File Name: NRC.java // // Student Name: Todd Wareham // // Login Name: harold // // MUN #: 8008765 // /////////////////////////////////////////////////////////////////You do not have to develop your code on our CS departmental systems. However, as your code will be compiled and tested on our CS departmental systems as part of the assignment marking process, you should ensure that your code compiles and runs correctly on at least one of these systems.
Created: November 14, 2005
Last Modified: November 14, 2005