I've been working on this one issue for 3 days and I'm stumped. We have to implement prim's algorithm using 2 maps(string, Vertex(class) and string,vector). The first one stores a letter as the name and pi and key within the vertex class. The 2nd map stores the letter name of a vertex and a vector of all its neigbors. I'm getting compile errors and it's because I'm having trouble accessing the elements of the vector within the map. Anyways, here's my code. (n.weight I know is wrong because it's an iterator but I need that neighbor class within that spot in the vector to access the weight variable)
void Graph::mst(string start){
string u;
if(vertices.find(start) != vertices.end()){
for (std::map<string,Vertex>::iterator it=vertices.begin(); it!=vertices.end(); ++it){
it->second.key = 100;
it->second.pi = "NIL";
}
vertices[start].key = 0;
for (std::map<string,Vertex>::iterator it=vertices.begin(); it!=vertices.end(); ++it){
minQ.insert(it->first, it->second.key);
}
u = minQ.extractMin();
while(u != "empty"){
cout << u << " " << vertices[u].pi << " " << vertices[u].key <<endl;
for (std::vector<Neighbor>::iterator v = adjList.find(u)->second.begin();
v!=adjList.find(u)->second.end(); ++v){
if(minQ.isMember(v->name) && vertices[u].key < (problem here)){
}
}
}
u = minQ.extractMin();
}
}