Assignment 7
Assignment
Write a Java program Dijkstra.java that
implements Dijkstra's Algorithm. Your program should read a network configuration
from a file and print the routing table for a selected source node. The
name of the network configuration file and the selected node appear on
the command line. For example, to print the routing table for node 4 of
a network defined in the file network1.data,
you would type
java Dijkstra network1.data 4
Be sure to include a check and an appropriate error message in case
the network does not contain the specified node.
Network Configuration File
A network configuration file contains an array of integers with the element
in row i and column j equal to the weight or cost of the
link from node i to node j. If there is no link between two
nodes, the corresponding array element is -1.
You will need to translate the -1
to a suitable approximation of infinity. The file
network1.data in the course directory
/Classes/CS322 contains the network configuration file for the example
discussed in class. For this assignment, you may assume that a network
has no more than 10 nodes.
Routing Table
The routing table for a source node should contain three columns labeled
"Destination", "Next Node", and "Cost". For the example discussed in class,
the routing table for source node 1 would be printed as
Routing Table for Node 1
Destination Next Node Cost
----------------------------------
2 2 3
3 3 2
4 3 4
5 3 5
6 3 3
Groundrules
See the rules for programming assignments on the main course Webpage. You
may work individually or in teams of two or three people.
Submission
As noted on the main course Webpage, assignments are to be submitted electronically
as e-mail attachments. Use the address
contst10@cs.gettysburg.edu
The e-mail message itself must contain the Honor Pledge and the full
names of the people submitting the assignment. Only one submission should
be made for each team.
Due Date and Time
This assignment is due at 12:01 AM on Monday, April 9. Late work is not
accepted, but early submissions are welcome!