Implementing dijkstras shortest-path algorithm

Assignment Help JAVA Programming
Reference no: EM13720963

Question 1. Your program should start by reading in the data-file, cities.txt, that has been provided.

This file contains a set of several hundred major cities, along with their longitude and latitude, in degrees. Your program should create a weighted graph structure: in the graph, each vertex stores a single city, and cities that are less than 2000 miles apart are connected to one another by edges, representing a direct flight between the cities, where each edge also has a weight equal to the distance between the cities. For distance calculations, we will use the Haversine Formula, which can take in two points on the globe and give the distance between them.

You should write code to do this calculation, returning the distance in miles between two points as a double value. (Note: for this to work, the inputs to any of the trigonometry functions must be in the form of radians, not degrees. All of the methods you need for this calculation can be found in the Math class.)

Question 2. Once the graph is created, the program should prompt the user for pairs of cities. If the two cities are found in the graph, then it should run a version of Dijkstra's algorithm to find the shortest path between them (many of these paths are quite indirect, since the graph assumes that no direct flight of longer than 2000 miles is possible). The code should continue prompting the user for input until they enter "Q" to quit. If the user enters anything that is not a city in the graph, then the process should start again, asking for a new pair of cities.

When it finds a route between the two cities, it should return that route, along with its total length in miles (truncated to an integer value for output purposes).

For precise output format and behavior, see the demonstration videos that were posted with this assignment, or the sample run included with this document.

Question 3. To improve efficiency of the program, you should add some caching to it. That is, if a user searches more than once for a route between one pair of cities during a single run of the program, it should not re-compute that route using Dijkstra's algorithm. Instead, it should save all search results that it has generated as it goes, and if asked for one that it has already performed, simply return that path.

Reference no: EM13720963

Questions Cloud

What is the jet centripetal acceleration : A jet fighter flying at 300 m/s (just below the speed of sound) makes a turn of radius 2.65km. What is its centripetal acceleration in gs
Prepare a 2012 taxable income statement table : Prepare a 2012 taxable income statement table for the partnership for 2012 - taxable income partnership income statement include the land sale total gain and allocate this gain to the partners
Snells lam of refraction by tracing the direction : Verify Snell's Lam of refraction by tracing and measuring the direction of refracted light rays through a change in medium. If we replaced the water dish with a solid glass disk of the same shape, explain how your data would be different
Describe a plan of action for implementing the strategy : What are the most important elements of a plan of action for implementing the strategy
Implementing dijkstras shortest-path algorithm : Implementing Dijkstras shortest-path algorithm - To improve efficiency of the program, you should add some caching to it
Responsibility to successfully completing treatment goals : Reflect on a treatment plan for yourself as a drug counselor. Identify services you could use to meet your goals as a drug counselor. What is your responsibility in achieving your goal? How is this similar to your clients' responsibility to succes..
Presentation for the executive staff or board of directors : You are an executive for Oprah Enterprise and you are preparing a presentation for the executive staff or board of directors about the organization's direction.
Identify two technological innovations : Identify two (2) technological innovations that have changed the fundamental manner in which companies have conducted business over the last 20 years, and recognize one (1) aspect of each that has impacted your own career. What piece of technology..
Prepare paper on prevention of maritime terrorism : Prepare paper on Prevention of Maritime Terrorism: The Container Security Initiative

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java program that will prompt the user to input a file

Write a Java program that will prompt the user to input a file (document) in order to count the frequency of each word. This program will display the frequency of each word sorted alphabetically or by frequency (depending on the preference of the use..

  Create a gui application with jframe

Create a GUI application with JFrame that contains five labels describing reasons that a customer might not buy a specific product (e.g. too expensive).

  Java socket hello i need to this assignment done in net

hello i need to this assignment done in net beans . and i want comment in code .also screen shots of running program

  Numerical solution of a two-point boundary-value problem

How to combine both Secant and Runge-Kutta methods and make it to the two-point boundary-value - Numerical Solution of a Two-Point Boundary

  Your task for this project is to design a program to help a

your task for this project is to design a program to help a videorental store operatorrecord clients transactions. the

  Web engineering principles

web application development, Web Engineering methodology, UML-based Web Engineering (UWE), models to the expansion of web applications, Object Oriented Web Solutions (OOWS),Web Modeling Language (WebML) methodology, Object-Oriented Hypermedia Design..

  Make a fourth button called special

Make a fourth button called "special" that does something else notdescribed in the assignment, such as change the background color.

  Write a java program that reads a five-line address

Write a Java program that reads a five-line address from an input file and produces an output file with the address repeated 50 times in three columns.

  Write the flow of execution of application

Write the flow of execution of application step by step and briefly explain the functionality of each function being called (like the first step would be to instantiate Frame and then instantiate Panel and place it into the Frame).

  Create a complete java application

Create a complete Java application that meets these requirements and the program has an opening comments section (using block comments) with the file name, date, your name, and purpose of the program.

  Create a book class for the library application project

Create a Book class for the Library application project. In addition to properties of author and isbn, with setters/getters, the Book should override Object's base method "boolean equals(Object)" and have a "boolean validate()" method.

  Which a ball is released from a user-defined height

Write a program in which a ball is released from a user-defined height and free-falls to the ground. The ball is pulled by earth's gravity of 9.8 m/sec 2 . Assume that each pixel represents

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