You will note in the code that there is both a getShortestPath and a computeShortestPaths function. Each time you hit solve and show a path, display the time required for each version, and the times speedup of the heap implementation over the array implementation. While both versions have the same "high-level" big-O complexity for the graphs they generate, they will differ significantly in their runtime (why?). (Use the standard Dijkstra's algorithm from the text which puts all nodes initially in the queue and finds the shortest path from the source node to all nodes in the network after running that, then you just need to show the path from the source to the destination.) Both versions should give you the same path cost. The “Compute” button should (potentially) call two different versions of Dijkstra’s, one that uses an array to implement the priority queue, and one that uses a heap. Clicking on the screen again will clear the current path while allowing you to set another source/destination pair. If the destination cannot be reached from the source then put “unreachable” in the total cost box. Also, in the "Total Path Cost" box, display the total path cost. Next to each edge between two nodes, display the cost of that segment of the route. After these nodes are selected you can hit “Compute”, and your code should draw the shortest path starting from the source node and following all intermediate nodes until the destination node. You can hit “Generate” again to build a new graph (if you change the random seed).Īfter generating, clicking on a node (or entering its index in the appropriate box) will highlight the source in green, and clicking another (or, again entering its index in the box) will highlight the destination in red. The nodes are drawn on the display in the provided framework. The nodes have an ( x, y) location and the edges include the start/end nodes and the edge length. You will be passed a graph structure which is comprised of | V| nodes, each with 3 edges, thus | E| = 3 | V| = O(| V|). Thus all nodes will have an out-degree of 3, but no predictable value for in-degree. The edges are directed and the edge cost is the Euclidean distance between the nodes. When you hit “Generate” the framework for this project generates a random set of nodes, V, each with 3 randomly selected edges to other nodes. A display for the graph vertices and for the subsequently computed shortest paths.
0 Comments
Leave a Reply. |