I'm currently writing a program to implement Dijkstra's algorithm, and decided on using a map object to hold vertices(map key) and the connected vertices paired with the path distance(map value). The connected vertices are paired with the distances like a coordinate pair. Example text file input follows:
1 2,3 3,2
2 4,4
3 2,1 4,2 5,3
4 5,2 6,1
5 6,2
6 1,9
The first number in each line would be read in as a key, where the coordinate pairs would be read into a vector initialized to hold pairs.
I tried using >> with a dummy for the comma, where a and b are the coordinates like:
for(myfile >> key >> a >> dummy >> b){
//assignment to map here
}
But this doesnt seem like it'd work because there can be more than one coordinate pair in one line.
How would I go about this? I'm newer to C++ and files are still a bit mind-boggling, any help or a couple of steps in the right direction would be great.