Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave
Shortest and Second Shortest Path Problem in Graphs
Answered

Problem Statement

This assignment involves an extension to the single source - single destination shortest path problem.

1. Open the text file "ass3.txt". (Note: "ass3.txt" should be a hardcoded as a constant.)

2. Read a graph from the file.

3. Find the shortest path between the start and goal vertices specified in the file.

4. Print out the vertices on the path, in order from start to goal.

5. Print out the length of this path and the total number of vertices visited.

6. Devise a strategy for determining the second shortest path between the vertices.

7. Find the second shortest path between the start and goal vertices specified in the file.

8. Print out the vertices on the path, in order from start to goal.

9. Print out the length of this path and the total number of vertices visited.

10. Optimize your shortest and second shortest path algorithms to improve their performance. 

• Two integers: nVertices and nEdges, the number of vertices and edges in the graph.

• nVertices triples consisting of the label and the x- and y-coordinates of each vertex.

• nEdges triples consisting of the labels of the start and end vertices of each edge, along with its weight.

Note: the weight associated with an edge will be greater than or equal to the Euclidean distance between its start and end vertices as determined by their coordinates.

• Two labels, the indicating the start and goal vertices for which the paths are required. 


A proposed solution to the second shortest path problem is as follows: For each edge e1 on the shortest path: Find the shortest path on (V, E— le,)). //shortest path without edge ei.

Think about this! Is this proposed solution correct always?

• What if we require that the second shortest path be longer than the shortest path?

• What if the graph contains cycles?

• What if the graph is undirected?

Explain your answers. If necessary explain how you might modify the proposed algorithm to address any issues that you identify.

Note: you may implement either the proposed solution or any modification you develop. You are not required to implement a modified proposal if you do not wish to do so. 

(Week-I0 demo, 2 marks) For step I. you should mad the data file into adjacency lists, or an adjacency matrix, and print on the screen the first 5 vertices and the vertices they are connected to together with their weights. e.g.: 


a: b: c: c(35) d(35) b(125) d(27) g(27) •(20) • (48) f(56) h(31) 


. . . Note: The data shown above is for format purposes only. 

(Discovering the Shortest Path) (2 marks) For step 2. you should implement Dijkstra's algorithm and find the shortest path between the start and goal vertices specified in the input file. Print out the vertices on the path (in order front start to goal). the length of this path and the total number of nodes visited by the algorithm to discover the shortest path. 

(Discovering the Second Shortest Path) (4 marks) For step 3, you should devise a strategy for determining the second shortest path between the start and goal vertices specified in the file and implement your solution. Print out the vertices on the path (in order from start to goal), the length of this path and the total number of nodes visited by the algorithm to discover the second shortest path. 

(Optimisation) (2 marks) For step 4. implement the A* algorithm and repeat Step-2 and Step-3. Print the same information to show the improved performance.

(Report) (2 marks) In a comment block at the bottom of your program (no more than 30 lines of text) list the data structures used by your program and describe your solution to the second shortest path problem. Also, provide answer to the questions. For this step. marks will be awarded based on accuracy and correctness. 

All programs submitted must compile and run on banshee: C: gcc ass2.c C++: g++ ass2.cpp Java: javac ass2.java Python: python ass2.py.


• Programs which do not compile on banshee with the above commands will receive zero marks. It is your responsibility to ensure that your program compiles and runs correctly. 

support
Whatsapp
callback
sales
sales chat
Whatsapp
callback
sales chat
close