Chat with us, powered by LiveChat Computer Science Homework | Writedemy

Computer Science Homework

Computer Science Homework

.Purpose

The purpose of this assignment is to implement graph algorithms for finding the shortest path from a source node to a destination node on a map.

Note: You CAN use ADTs such as TreeMap defined in Java library for this assignment. See TreeMap at https://docs.oracle.com/javase/7/docs/api/java/util/TreeMap.html

 

2.Description

For this programming assignment, you will implement a graph using an adjacency list representation.  Your program will read a graph from a file called map.txt.  The file is a text file where the first line contains two numbers.  The first is the number of vertices n and the second is the number of edges m.   After this line there will be n lines with three numbers representing node locations on a map. The first number represent the vertex ID, and the next two numbers representing (x, y) coordinates for the vertex. Then there will be m lines with three numbers representing edges and their weights. The first two numbers represent the source and destination vertex for the undirected edge.  The third number is the weight for that edge.  Your program should ask the user to enter the source and the destination and run Dijkstra’s shortest path algorithm to return the shortest path from the source to the destination.  An example map.txt file would be:

4        5

0                    10  10 vertex 0’s location is at (10, 10)

1                    90    40

2                    30  10 vertex 1’s location is at (90, 40)

3       90     10

0                    2     1 edge connecting nodes 0 and 2 with weight 1

1                    2     5

2                    3     3

1        3        2

0        3       10  edge connecting nodes 0 and 3 with weight 10

 

 

This file represents a graph with 4 vertices, 5 edges, and has edges (0, 2) with weight 1, (1,2) with weight 5, (2,3) with weight 3, (1,3) with weight 2, (0,3) with weight 10.  The graph is undirected; that is, for each edge (v, w), you should add v w and w v with the same weight in your program. Your program should output the shortest path (e.g., output the shortest path between vertex 0 and vertex 3 as a sequence of vertex labels 0, 2, 3).  NOTE: The weight does NOT have to be an integer.  In general the weight will be a floating point number.

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order