Code: ECS206
IT Assessment Answer
Assignment Task: ECS206
In this assignment, you will implement Dijkstra’s Algorithm for finding the shortest paths from a given source in a weighted directed graph. Your job will be translating the pseudo-code given in class into actual working code in C, C++ or JAVA. By doing this assignment, you will learn how to handle a graph as a data structure in a computer program. There are many interesting details that you will need to work out. One particularly interesting detail is the implementation of the priority queue. In this assignment, you will need to implement the priority queue as a heap. You can do your own implementation of a heap or use the heap implementation from your programming language’s library if you can get that to work well. The input to the program is a textual representation of a weighted directed graph as detailed below. The output is a list of shortest path lengths (one per vertex) as described below. Let the input file name be “input.txt” and the output file name be “output.txt”.
The textual representation of the graph consists of one line with two integers specifying the number of vertices and the number of edges, respectively, followed by a list of edges (one line per edge). If the number of vertices is V, assume, without any loss of generality, that the vertices are numbered 0 through V-1, and that the source is Vertex 0. The line for each edge consists of three numbers representing the source vertex, the destination vertex and the edge weight, respectively.ECS206
The output shows the shortest distance for each vertex. The first line in the output starts with the word “Vertex” followed by vertex numbers in order. The second line starts with the word “Distance”, followed by the shortest distances in order.
For example, here is the input and the output for the graph used to illustrate the Dijkstra’s algorithm in class (the graph should be in your notes):
Input:
5 10
0 1 10
0 4 5
1 2 1
1 4 2
2 3 4
3 0 7
3 2 6
4 1 3
4 2 9
4 3 2
Output:
Vertex 0 1 2 3 4
Distance 0 8 9 7 5
In the above example, the graph has 5 vertices and 10 edges. The first edge is from Vertex 0 to Vertex 1 and has a weight of 10, and so on. ECS206
This IT Assessment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.