0

I have two files; one with places then the distance between them.

Example:
Moffat Carlisle 65
Doncaster Hull 76
Northampton Birmingham 90
Leicester Lincoln 82
Sheffield Birmingham 122


I was wanting to use dijkstra's method, but i seem to have a problem because looking pseudo codes to understand it they all ask for a node, then all the connecting nodes. The problem is that the file is unordered so it will keep changing nodes. I thought i could search if it's already in the array/vector. If not then add it, but the problem with this is i don't know how many connecting nodes there is, so i would have to include a expanding varible.

The second file, contains a source city and dest city, which i have to work out the shortest path.

hope you can help!

2
Contributors
1
Reply
4
Views
6 Years
Discussion Span
Last Post by VernonDozier
0

Not sure what the question is. If it's "How do I set up/add to a colection if I don't know the size?", you've already answered yourself:

>> I thought i could search if it's already in the array/vector.

>> so i would have to include a expanding varible.

Vectors are tailor-made for this.


>> The problem is that the file is unordered so it will keep changing nodes.

If you think an "ordered" file will help, then set up some ordering criteria and sort it so it's ordered.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.