473,462 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Very urgent, please help - Min Time Cost Problem (Dijkstra’s algorithm)

D.K. is traveling from City A to City B. He can stop at some designated spots only.
I am trying to use Dijkstra’s algorithm to determine the “spot-to-spot” path that will get D.K. from City A to the City B in the minimum amount of time.

The input in my program is an integer n and the 2D coordinates of n spots.

Some assumptions have been made about the physical layout of the problem:
1) All the spots are considered to be in a square of side 1600 km. A coordinate system is laid out for this square so that the lower left corner of the square is at the origin.
2) The coordinates of City A are (0, 1600) and the City B is at (1600, 0).
3) There is no “clumping” of spots. This means that for any pair of spots, the difference in their xcoordinates is >= 40 km or the difference in their y-coordinates is >= 40 km.
4) As the input size n increases for other problem instances, the clumping constraint may require that the area of the square must also increase. In other words, I am not allowed to assume that the number of spots is bounded above by some constant.

In addition, D.K. may choose to travel at either speed of the following:
Option 1: D.K. can travel at 10 km/hr but can only travel for 10 hours at this speed when he is still energetic
Option 2: D.K. can travel faster at 20 km/hr but can only last for 5 hours even though he has been out of energy.

That is, D.K. can travel up to 200km between spots: travel at 10km/hr for 10 hours and then travel at 20 km/hr for 5 hours.

(Because of these constraints, it is quite possible to have input data that will cause the algorithm to claim that the trip from City A to the City B cannot be done)

It is obvious that there is a limitation on distance traveled between spots because of the time limitations imposed by the constraints above, so I don’t want to use a complete graph to describe the distances between all the spots. I want a sparse graph represented by an adjacency list instead.

However, this adjacency list is built only after building a data structure that can provide a list of spots that are close by to any given spot. Once this is accomplished, I can add time costs to the graph edges.

So, my question is how I should build the data structure that can satisfy the following query: For a given “query” spot Q, find all nearby spots.

Could someone kindly suggest some pseudo-code that describes how the data structure is built? And I hope the construction of the adjacency list is faster than theta(n^2).

Thanks a loooooooooooooot in advance!!
Nov 10 '07 #1
1 2338
r035198x
13,262 8TB
D.K. is traveling from City A to City B. He can stop at some designated spots only.
I am trying to use Dijkstra’s algorithm to determine the “spot-to-spot” path that will get D.K. from City A to the City B in the minimum amount of time.

The input in my program is an integer n and the 2D coordinates of n spots.

Some assumptions have been made about the physical layout of the problem:
1) All the spots are considered to be in a square of side 1600 km. A coordinate system is laid out for this square so that the lower left corner of the square is at the origin.
2) The coordinates of City A are (0, 1600) and the City B is at (1600, 0).
3) There is no “clumping” of spots. This means that for any pair of spots, the difference in their xcoordinates is >= 40 km or the difference in their y-coordinates is >= 40 km.
4) As the input size n increases for other problem instances, the clumping constraint may require that the area of the square must also increase. In other words, I am not allowed to assume that the number of spots is bounded above by some constant.

In addition, D.K. may choose to travel at either speed of the following:
Option 1: D.K. can travel at 10 km/hr but can only travel for 10 hours at this speed when he is still energetic
Option 2: D.K. can travel faster at 20 km/hr but can only last for 5 hours even though he has been out of energy.

That is, D.K. can travel up to 200km between spots: travel at 10km/hr for 10 hours and then travel at 20 km/hr for 5 hours.

(Because of these constraints, it is quite possible to have input data that will cause the algorithm to claim that the trip from City A to the City B cannot be done)

It is obvious that there is a limitation on distance traveled between spots because of the time limitations imposed by the constraints above, so I don’t want to use a complete graph to describe the distances between all the spots. I want a sparse graph represented by an adjacency list instead.

However, this adjacency list is built only after building a data structure that can provide a list of spots that are close by to any given spot. Once this is accomplished, I can add time costs to the graph edges.

So, my question is how I should build the data structure that can satisfy the following query: For a given “query” spot Q, find all nearby spots.

Could someone kindly suggest some pseudo-code that describes how the data structure is built? And I hope the construction of the adjacency list is faster than theta(n^2).

Thanks a loooooooooooooot in advance!!
This article should be able to give you some pointers on how to get started.
Nov 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Der Andere | last post by:
Do you know of an efficient implementation (priority queues) of Dijkstra's algorithm for calculating the shortest distances between vertices in a graph? Cheers, Matthias -- Für emails...
2
by: Ricardo Batista | last post by:
I need that someone help me. I need to program the dijkstra algorithm by object oriented. I'll send my code. #!/usr/bin/env python # -*- encoding: latin -*- NIL =
3
by: A_StClaire_ | last post by:
implemented Dijkstra's algorithm as follows. plz pour on the negative criticism cuz I know I have a ton to learn. oh, before you flame me regarding the language, my class was told to do this in...
1
by: AvrilComplic8ed | last post by:
Hello there I wonder if you can help me. I am creating a loans system for a make-believe CD rental company, in Microsoft Access. I have 3 tables: CD details, Member Details, and Loan Details. I...
5
by: A_StClaire_ | last post by:
thoughts or criticism anyone? using System; namespace Dijkstra { public class Algorithm { private const int nodes = 10;
3
by: Ook | last post by:
This is probably a bit OT, as I'm not looking for a c++ implementaiton of Dijkstra's algorithm, rather I'm just trying to understand it (is there a better place then here to ask this question?)....
8
by: abhradwip | last post by:
I want to write a program which will find the shortest path between n no. of cities using dijkstra's algorithm ...... but could not do it..... i have written a program which will give the shortest...
1
by: chaos | last post by:
Hi all, anyone know what is Dijkstra algorithm . what is the code for Dijkstra algorithm
3
by: victorporton | last post by:
D.K. is traveling from City A to City B. He can stop at some designated spots only. I am trying to use Dijkstra’s algorithm to determine the “spot-to-spot” path that will get D.K. from City A to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.