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!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.