Question
Task: Write a Program that computes the shortest distance between any two routers in a network based on the Dijkstra Algorithm. The algorithm involves finding
Task: Write a Program that computes the shortest distance between any two routers in a network based on the Dijkstra Algorithm. The algorithm involves finding the shortest spanning tree between a pair of graph nodes Input Files you need to create; 1) Graph.dat: In this file you need to specify the following a. Number of Vertices (i.e. nodes) b. A weighted graph represented in the form of adjacent list c. For each vertex, you need to keep a list of their weights (weights range from 0 to 9. A weight of 0 means there is no edge (branch) between the two vertices. 2) Input.dat: In this file you need to specify the following a. Multiple sets of source and destination vertices. b. Use FF to indicate the end of a set of source and destination pair and a 0 to represent the end of all input sets Run the simulation Results should be written in an output file as follows: 3) Output.dat: For each set of inputs, you need a. Write out the weighted path length (i.e. total distance between a pair of nodes) followed by b. Vertices of the entire shortest path from source to destination c. If there are multiple paths with the same weighted shortest path length choose the one with the minimum number of hops d. Use FFFF to indicate the end of a set of input and 0 to represent the end of all inputs.
An example of the above output file is 6 1 4 3 FFFF 15 5 1 4 2 FFFF And so on The above means: The shortest distance between nodes 1 and 3 is 6 and the path is 1---4- --3. The shortest distance between nodes 5 and 2 is 15 and the path is 5---1---4---2and so on.
An example of the input file is 1 2 FF 1 3
FF and so on. The first pair is (1, 2), the first entry represent the source, the second represent the destination and so on...
code c or java doesnt matter what language .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started