
Shortest path problem
I did a seach and came up with several posts, some dealing with A*, some with Dijkstra's shortest path algorithms, others with breadth first search.
I think I am missing something because I cannot figure out how to use any of that for what I need.
For my project I am given a number, and all the other numbers I can move to from that one via an INI, I can read the ini and pull those #'s out fine
example ini
[numbers]
1=2,5,6
2=1,3,5,6
3=2,4,6,7,8
4=3,7,8
5=1,2,6,9,10
6=1,2,3,5,7,9,10,11
...
16=11,12,15
The example above will build something like
1 : 2 : 3 : 4
5 : 6 : 7 : 8
9 : 10 : 11: 12
13 : 14 : 15 : 16
Now given my starting number and the number I want to arive at I need to find the shortest path, so say I want to start at 1 and get to 16, the shortest path is 1>6>11>16
How would I use any of the shortest path algorithms, if any, to do what I need it to do with the information I am given. It would also need to handle a case like
[numbers]
1=2
2=1,3,4,5
3=2,4,5,6,16
4=2,3,5,10,11
...
16=12,13,14,15
Does not make a nice square grid to write out
So the shortest path from 1 to 16 is 1>2>3>16 but the shortest path back is not the same.
I hope what I need is clear enough, if not I'll try to clerify for you