我找不到我的程序引发 SIGBART 错误的原因。
调用此函数时,我已将其范围缩小。
bool Node::isEdgeConnected(Node vertex1, Node vertex2){
//I'm not sure if this is the right way to copy this vector <list>
vector<list<Node> > myEdgeList = *edgeList;//edgeList is a private data member of Node
vector<list<Node> >::iterator it;
cout << myEdgeList.size();
for (it = myEdgeList.begin(); it != myEdgeList.end(); it++) {
list<Node> edge;
edge = *it;
Node placeNode = edge.front();
cout <<placeNode.getNodeId()<<endl;
list<Node>::iterator eIt;
for (eIt = edge.begin(); eIt != edge.end(); eIt++) {
Node placeNode1, placeNode2;
placeNode1 = edge.front();
placeNode2 = *eIt;
cout << placeNode1.getNodeId() << " " << placeNode2.getNodeId()<<endl;
if(placeNode1.getNodeId() == vertex1.getNodeId() &&
placeNode2.getNodeId() == vertex2.getNodeId()){
return true;
}
}
}
return false;
}
任何帮助,将不胜感激。