Я получаю это сообщение об ошибке map/set iterator not dereferencable
При попытке получить значение по ключу в multimap
. В этом коде я пытаюсь показать неориентированный граф, представленный список смежности (vector<Vertex*> vertexList
)map/set итератор не разменяем. Multimap container isse
void NonOrGraph::show() {
cout << endl;
multimap<int, int> used;
for (int i = 0; i < vertexList.size(); i++) {
if (vertexList[i]->adjMap.empty()) {
cout << vertexList[i]->index << " isolated";
} else {
for(map<Vertex*, int>::iterator it = vertexList[i]->adjMap.begin();
it != vertexList[i]->adjMap.end();
it++)
{
int from = vertexList[i]->index;
int to = it->first->index;
int weight = it->second;
used.insert(pair<int, int>(from, to));
if (used.find(to)->second != from) {
cout << from << " <--(" << weight << ")--> " << to << endl;
}
}
}
}
cout << "\n\n";
}
Пожалуйста, пост [Минимум, полный, Проверяемость пример] (http://www.stackoverflow.com/help/mcve). – Barry