I am trying to read a file in c++ and populate my vector which represents an adjacency list.The file contains an adjacency list representation of an undirected weighted graph.Each row consists of the node tuples that are adjacent to that particular vertex along with the length of that edge. For example, the 6th row has 6 as the first entry indicating that this row corresponds to the vertex labeled 6. The next entry of this row "141,8200" indicates that there is an edge between vertex 6 and vertex 141 that has length 8200. The rest of the pairs of this row indicate the other vertices adjacent to vertex 6 and the lengths of the corresponding edges.
File eg:-
1 3,4 2,20 5,89
2 4,7 1,102
ifstream ifs;
string line;
ifs.open("dijkstraData.txt");
cout<<log(vertices)<<" "<<loops<<endl;
std::vector<vector < std::pair < int,int > > > CadjList(vertices);
while(getline(ifs,line)){
// transfer the line contents to line_stream
stringstream line_stream(line);
//now what
}