New class for graphs with weighted edges

Assignment Help Basic Computer Science
Reference no: EM13925112

Implement a new class for graphs with weighted edges. Either you use the ordinary Graph class as a superclass for your implementation, or you start it from scratch by following the pattern used in the ordinary Graph class. The ordinary Graph class is implemented by Michael Main which can be downloaded from his website.

After implementing the new class, provide two extra methods to implement Dijkstra's shortest distance and shortest path algorithms as described on pages 732-743 of the third edition or pages 760-771 of the fourth edition. Please carefully read the algorithm explanation and examples in those pages so that you fully understand the whole algorithms.

The shortest path algorithms only differ from the base shortest distance algorithm in keeping a record of previous vertex for each vertex. It would be helpful to write a method for printing a path from the start vertex to a given vertex as a list of vertices on the path.
After you implement the weighted graph as requested above, write a program to help a traveler plan the shortest traveling path from one city to another. I expect your program should read a file of data containing information about a group of cities and create a graph for this group of data. The file takes the following format. In the first line of the file is the number of cities interested in the program. Then each line of the file contains three integers. The first two are the indices of cities and the third one is the distance between two cities indexed by indices (suppose that distances are integers). There is another file consisting of pairs of index (an integer) and city names (String). Doing so can make your program simpler in building graph objects. Your program needs to read in the second file too.

For example, the below may be the content of such as files:

distance.txt
5
0 3 215
1 3 731
2 4 337
4 0 280
1 2 823
Index.txt
0 town 1
1 town 2
2 town 3
3 town 4
4 town 5

Please produce your own distance and index files so that you must have at least twenty cities and specify at least 30 distances. You don't need to provide the actual distance between known cities.
Finally your program allows the user to enter queries of the form "City1, City2" and have the program print the shortest sequence of path to travel from City1 to City2.

Reference no: EM13925112

Questions Cloud

Generally used in preparing a statement of cash flows : One of Astro Company's activity cost pools is machine setups, with estimated overhead of $150,000. Astro produces sparklers (400 setups) and lighters (600 setups). How much of the machine setup cost pool should be assigned to sparklers?
What is a non-cyclical industry and give a few examples : What is a non-cyclical industry? Give a few examples. What other industries would be impacted, either concurrently or shortly thereafter?
Wi-fi security in a wireless network : Create a policy for 802.11 Wi-Fi security in a wireless network in a 500-employee company with a 47-access point WLAN. This is not a trivial task.
Effective compensation and benefit system : How an effective compensation and benefit system contributes to organizational effectiveness. The principle components of your revised compensation and benefit system for a large-scale organization as well as a recommendation for each component.
New class for graphs with weighted edges : Implement a new class for graphs with weighted edges. Either you use the ordinary Graph class as a superclass for your implementation, or you start it from scratch by following the pattern used in the ordinary Graph class. The ordinary Graph class..
Compute ending inventory : Boyne Inc. had beginning inventory of $18,000 at cost and $20,900 at retail. Net purchases were $131,590 at cost and $181,700 at retail. Net markups were $11,100; net markdowns were $8,200;
Analyze the key reasons for the divergent performance : Read a business newspaper or other business publications and identify four industries that are doing well currently and four industries that are under-performing. Analyze the key reasons for the divergent performance.
Analysis-companies does have strong strategic intent posture : Conduct a thorough and well-argued analysis that provides evidence that one of your chosen companies does have a strong strategic-intent posture.
Successfully funding your business venture : For Assignment 1, you imagined that you were going to start a company that offered an innovative product or service. In Assignment 1 you also determined the business structure you would use for that venture. For this assignment, you can use that s..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  A relational database model allows database users to analyze

"Relational Set Operators"Please respond to the following: A relational Database Model allows database users to analyze data thoroughly. To accomplish this, advanced commands such as UNION and INTERSECT may be used.  Describe a business scenario wher..

  How would you measure product quality

How would you measure product quality in  Agile project management?

  Why does the label control that contains your name print

why does the label control that contains your name print above the page number?

  Show even-parity encoding of bit string in form of bytes

Show the even-parity encoding of the following bit string, in the form of bytes: 0100101011101011101010110110 (break it up into pieces of data large enough to encode as several parity-encoded bytes.

  About mis200

What features of this software would be especially attractive to a company like Evolution Homecare? Why do you think Evolution chose Microsoft and its CRM vendors?

  Analyse the average of pre-test raw score

Enter the data in excel spreadsheet and analyse the average of Pre-Test Raw Score and post-Test Raw Score,present your answer in two slides

  What is included in the full course package

What is included in the full course package. The entire course study guide includes the homework solution in notepad for DBM

  Represent valid comments

Java, C#, and C++ all allow use of comments. Which of the following represent(s) valid comments in these three languages

  Use an open-addressed hashing table of size m

1)Suppose that we use an open-addressed hashing table of size m to store n ? m / 2 items. Assuming uniform hashing, show that for i = 1, 2, ..., n, the probability is at most 2?k that the i-th insertion requires strictly more than k probes.

  Why is rarp used in one case versus arp

Why is RARP used in one case versus ARP? This one is complex and I don't know how to do it

  Write a script that creates and calls a stored procedure

Write a script that creates and calls a stored procedure named insert_category. First, code a statement that creates a procedure that adds a new row to the Categories table. To do that, this procedure should have one parameter for the category name.

  Develop an i/o port decoder

Using a PLD, develop an I/O port decoder that generates the following high-bank I/O strobes: 300DH, 300BH, 00B6H, and 00EEH.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd