Question: Calculate the paths of a simulated network using the three following algorithms from the supplied text, comparing run times of each Table 4 . 4

Calculate the paths of a simulated network using the three following algorithms from the supplied text, comparing run times of each
Table 4.4 Distance-Vector Routing Algorithm for A Node
Distance_Vector_Routing ()
{
// Initialize (create initial vectors for the node)
D[myself]=0
for ( y =1 to N)
{
if (}y\mathrm{ is a neighbor)
D[y]=c[myself[y]
else
D[y]=\infty
}
send vector {D[1], D[2],..., D[N]} to all neighbors
// Update (improve the vector with the vector received from a neighbor)
repeat (forever)
{
wait (for a vector D
for ( y =1 to N)
{
D[y]=min [D[y],(c[myself][w]+ D
}
if (any change in the vector)
send vector {D[1], D[2],...,D[N]} to all neighbors
}
}// End of Distance Vector
Dijkstra's Algorithm ()
{
// Initialization
Tree ={root }// Tree is made only of the root
for ( y=1 to N)// N is the number of nodes
{
if (}y\mathrm{ is the root)
D[y]=0// D [y] is shortest distance from root to node y
else if (}y\mathrm{ is a neighbor)
D[y]=c[root][y]// c[x][y] is cost between nodes x and y in LSDB
else
D[y]=\infty
}
// Calculation
repeat
{
find a node w, with D[w] minimum among all nodes not in the Tree
// Update distances for all neighbor of w
for (every node x, which is neighbor of w and not in the Tree)
{
D [ x ]=\operatorname { m i n }{ D [ x ],( D [ w ]+ c [ w ][ x ])}
}
} until (all nodes included in the Tree)
}// End of Dijkstra
Table 4.6 Path-vector algorithm for a node
Path_Vector_Routing ()
{
// Initialization
for ( y = l to N)
{
if (y is myself)
Path [y]= myself
else if (y is a neighbor)
Path[y]= myself + neighbor node
else
Path [y]= empty
}
Send vector {Path[1], Path[2],..., Path[y]} to all neighbors
// Update
repeat (forever)
{
wait (for a vector Path from a neighbor w)
for ( y = l to N)
{
if (Path $ includes myself)
discard the path // Avoid any loop
else
}
If (there is a change in the vector)
Send vector {Path[1], Path[2],..., Path[y]} to all neighbors
}
}// End of Path Vector
Input/output format and testing:
Your program should take a text file as input, which describes the network topology. The first line of the text file is a single number, which stands for the number of nodes in the network. With a network of \( n \) nodes, we assume the nodes have the following IDs: \(0,1,\ldots, n-1\). All subsequent lines in the input file are in the format of "\( n 1\) n2 cost", which stands for a link between node \( n 1\) and node \( n 2\) with cost cost. Note that cost can be a floating point number. These three numbers are separated by single spaces in each line of the input file. All the links are bidirectional. So a link of "n1 n2 cost " infers a link of "n2 n1 cost ". All links are sorted in ascending order with n 1 as the primary order and n 2 as the secondary order.
As output, your program should print out the shortest path to all network nodes with the complete path and the cost.
Let's look at an example with the network topology shown in the following figure.
```
Distance Vector Routing:
shortest path to node 1 is 0->1 with cost 2.0
shortest path to node 2 is 0->3->4->2 with cost 3.0
shortest path to node 3 is 0->3 with cost 1.0
shortest path to node 4 is 0->3->4 with cost 2.0
shortest path to node 5 is 0->3->4->5 with cost 4.0
Time Elapsed: 5 seconds
Djikstra's Algorithm:
....(Repeat for the other 2 algorithms)
```
Note that we will use DIFFERENT network topology in our testing. Note that we will use DIFFERENT network topology in our testing.
Turn-in:
You are asked to turn in a single source file and a README file. The source file should be named if you use C, if you use C++, and a if you use Java, and Distance.py if you use Python. In the case of Java, the main method class should also be in Distance such that your program can be launched as '" after compile. No matter what programming language you choose to use, your program should take two parameters on startup. The first parameter is the path of a text file describing the network topology. The second parameter is the ID of the source node. For example, if your program is written in Java, you should be able to run your program using "java Distance network. dat 0" to find shortest paths from node in the network topology specified by network.dat.
The README file should contain a description of your design, and a detailed analysis of the complexity of your program. If your program requires any special compilation flag to build, you need to specify the full build command in the README file. Alternatively, you can provide a makefile, which is strongly preferred.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!