FastestPathPossible Function

I want to build an INI file that has all 50 states and their connecting states, such as...
1
2
3
4
5
6
7
8
9
[North Carolina]
Connecting_States=4
ConnectingState1=Virginia
ConnectingState2=South Carolina
ConnectingState3=Tennessee
ConnectingState4=Kentucky

[RestOfStatesHere]
...


I'm really not even 100% sure if that's right, but anyway.. I want to be able to read the connecting states so that I can track the fastest method possible from 1 state to another. For example if I was in North Carolina and wanted to get to Washington then it would be able to tell me each state I could jump to so that I could get there fastest. So it would be a function like this...
1
2
3
4
5
6
7
void FindFastestPath(char state1, char state2)
{
    ReadINIHere;
    ReadAllConnectingStatesHere;
    PrintFastestMethodPossibleHere;
//Example FindFastestPath("north carolina", "florida");
//Prints out "North Carolina->South Carolina->Georgia->Florida" 
Last edited on
Well by your definition you want a shortest path function where length of path is defined by number of states travelling through.

I suggest googling shortest path
You would have to have an altogether very complex function. You would have to track from one state to all of its connecting states and then to all of the connecting state's connecting states. There is really no simple way to do this.

You could connect the program to mapquest and calculate it that way but I would have no clue how to do that.

I would start by making a huge network between all the states and storing it somewhere, then read the file in and analyze it.

example of the file:

@Florida - California
// a line showing the quickest route.

Excluding Alaska and Hawaii, you only have 50 * 48 or 2400 different paths to write.

If you worked on it all day you could get it done. Then the program would merely have to analyze the file looking for the correct header and then reading in the line below it for the path.

Note: This would probably be a little slow but it would work.
Last edited on
Topic archived. No new replies allowed.