![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2005
Posts: 1
Rep Power: 0
![]() |
Distance Finder Problem!
http://www.wrestlefury.com/DataFiles.zip
The zip file contains a map, a spread sheet of distances between these towns and two files of data extracted from the spread sheet. The extracted data is a list of the towns and a table of distances. Both these files have the number of entries in the file on the first line. Click the following link to see a picture of the program: http://www.wrestlefury.com/distancefinder.jpg I was wondering if anyone can help with the coding, i've got a bit of code which is underneath, but i still think this is fairly hard. I've created the Interface, just need to do the remainder of the code. Any code or hints will be very much appreciated. [PHP] private Hashtable _distances; int[,] distances _distances=new Hashtable(); Hashtable birminghamDistances=new Hashtable(); birminghamDistances.Add("Birmingham",0); birminghamDistances.Add("Cardiff",103); ... _distances.Add("Birmingham",birminghamDistances); // repeat for all towns [/PHP] |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Look up Dijkstra's shortest path algorithm. A Google search for "Dijkstra" should do it.
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
The easiest thing to do is plot each town on a grid of the scale that you want the distance in.
Then take the two towns and use this to calculate distance Distance = sqrt(abs(Town1.x - Town2.x) + (Town1.Y - Town2.y)))
__________________
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|