Suppose the graph represent the air Map of different cities in the world where the estimated time to travel are: \begin{tabular}{|c|c|} \hline Area Cover & Time(hours) \\ \hline Chengdu to Guangzhou & 2 \\ \hline Chengdu to Kolkata & 5 \\ \hline Chengdu to Kunming & 4 \\ \hline Guangzhou to Dhaka & 8 \\ \hline Guangzhou to Kolkata & 1 \\ \hline Kunming to Kolkata & 3 \\ \hline Kolkata to Dhaka & 3 \\ \hline Kunming to Dhaka & 2 \\ \hline \end{tabular} If you are a traveller which road will you choose to visit Chengdu to Dhaka? Why will you choose the road and explain your opinion based on Dijkstra's Shortest path algorithm. (points-10)
Added by Gregg M.
Close
Step 1
The nodes are Chengdu, Guangzhou, Kolkata, Kunming, and Dhaka. The edges with their respective travel times are: - Chengdu to Guangzhou: 2 hours - Chengdu to Kolkata: 5 hours - Chengdu to Kunming: 4 hours - Guangzhou to Dhaka: 8 hours - Guangzhou to Kolkata: 1 Show more…
Show all steps
Your feedback will help us improve your experience
Vysakh M and 66 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
FINDING MINIMUM SPANNING TREES WITH KRUSKAL'S ALGORITHM INTRODUCTION A graph G = (V,E) consists of a non-empty set V of vertices and a set E of pairs of vertices, called edges. When the vertices in the edges are unordered, the graph is undirected. A graph is connected if there is a path between any two of its vertices. If G is connected, a spanning tree on G is a maximal, acyclic subgraph of G; that is, it is a subgraph of G that connects all of G's vertices and contains no cycles. When weights or costs are associated with the edges of G, a minimum spanning tree (MST) for G is a spanning tree of G with the smallest possible total cost over all its edges. One algorithm for finding a minimum spanning tree is Kruskal's Algorithm, which examines the edges of G in ascending order of their weights and includes in the spanning tree each edge that does not complete a cycle. DESCRIPTION Design, implement, and test a program that reads a description of a weighted undirected graph from a file and applies Kruskal's Algorithm to construct a minimum spanning tree on the graph and report the cost of the spanning tree. The program will sort the graph's edges by their costs, then apply the union/find process to build minimum-cost connected components of the graph until all the graph's vertices belong to one connected component. INPUT Input to the program represents a connected weighted graph. In particular, the program reads a file that contains the number of vertices in a graph, then a list of the graph's edges. Each edge will be represented by its vertices and its cost: vi vj ci,j. The program prompts for the name of an input file and reads that name from the terminal. OUTPUT The program's output is a list of the edges in a minimum spanning tree for the graph and the total cost of that tree. The program directs its output to the terminal. ERRORS The program may assume that the input file is correct; it need not detect any errors. EXAMPLE This input file represents a weighted graph with seven vertices. The edge connecting v0 and v2 has cost 10, and so on. 7 0 2 10 0 3 13 1 2 20 1 3 5 1 6 21 1 4 18 2 5 17 3 5 16 4 5 22 4 6 25 The corresponding output might look like this: Minimum spanning tree: Edge = (v1,v3); cost = 5 Edge = (v0,v2); cost = 10 Edge = (v0,v3); cost = 13 Edge = (v3,v5); cost = 16 Edge = (v1,v4); cost = 18 Edge = (v1,v6); cost = 21 Total cost = 83 OTHER REQUIREMENTS Assume that no graph submitted to the program contains more than 50 vertices. Implement the Partition type in a class. On the printouts of your tests, draw the (smaller) graphs and their spanning trees as identified by your program. HINTS Use an array of records (structs) or a linked list ordered by edge weights to hold the edges and their costs. Be sure to document this choice. Note that since the number of vertices is limited to 50, no graph can contain more than (50 x 49) / 2 edges. Building test files will take some time, so start early.
Sri K.
Using Dijkstra's algorithm, find the shortest path between the vertices A and E.
Problem I: Route Planning A company representative lives in Louisville, Kentucky and needs to visit offices in five different Indiana cities over the next few days. The representative wants to drive between cities and return to Louisville at the end of the trip. The estimated driving times, in hours, between cities are given in the table below (along with a map of Indiana): a) Represent the driving times by a weighted graph. b) Use the greedy algorithm to design an efficient route for the representative to follow. How many hours does this route require? c) Use the edge-picking algorithm to design an efficient route for the representative to follow. How many hours does this route require? d) Which of the two previous routes best minimizes the representative's total driving time?
Madhur L.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD