Question: Carry out Dijkstra's shortest path algorithm on the graph below. Pseudocode as given in the lectures is as follows: shortestPath(in theGraph: Graph, in weight: WeightArray)//finds

Carry out Dijkstra's shortest path algorithm on the graph below. Pseudocode as given in the lectures is as follows: shortestPath(in theGraph: Graph, in weight: WeightArray)//finds the min-cost paths between an origin vertex and all other vertices//in a weighted directed graph: theGraph's weights are non-negative create a set vertexSet that contains only vertex 0 n = number of vertices in theGraph for (v = 0 through n-1) weight[v] = matrix[0][v]//invariant: weight[v] is the smallest weight to v from vertices in vertexSet for (step = 2 through n) find smallest weight[v] such that v is not in vertexSet add v to vertexSet for (all vertices u not in vertexSet) if (weight[u] > weight[v] + matrix[v][u]) weight[u] = weight[v] + matrix[v][u] In carrying out the algorithm, draw up the table and fill it out to show each step of the algorithm as in lectures. What is the shortest path from vertex 0 to vertex 4, and what is its length? b. Dijkstra's algorithm finds the shortest, (minimum cost) path from a single source vertex to any other vertex. Professor Smith is interested in finding the longest (maximum cost) path from a single source vertex to any other vertex. He proposes modifying Dijkstra's algorithm to do this, by just converting minima to maxima, smallest to largest, the initial distance for vertices not directly connected to the source set as - infinity instead of + infinity, etc. For example, weight [v] stores the largest weight to v from vertices in vertexSet: you update weight [u] if weight [u] > weight [v] + matrix [v] [u]: weight [4] is initialised to - infinity, etc. Do you think Professor Smith is correct? If so, give an example of the algorithm on a small graph. If not, similarly give an example on a small graph where it does not work
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
