Input file handling
I'm trying to figure out how to handle the format of this file to be used with Dijkstra - type algorithm.
It is a simple text file, with an unknown number of lines (easily created function to solve this). This is how it looks
city destination:weight destination:weight ....
2 3:50 1:70
3 5:10 1:50 2: 20 4:30
This basically says 1 can go to 2 with weight of 10. 2 can go to 3 with weight 50, or to 1 with weight 70...
There can be any number (numCities - 1) of destinations and weights per line. I'm having trouble thinking of how to store the cities with their destinations and weights. I thought about trying to use structs / linked lists but with the unknown amounts (particularly for pointers, city->weight1 city->weight I don't think this would be feasible. Any suggestions?
why not a structure or class with the following members:
so that it's easy to add an arbitrary number without having to worry about memory.