VertSet intersection(const VertSet &set1, const VertSet &set2) { VertSet result = VertSet(); for (VertSet_const_IT it = set1.begin(); it != set1.end(); it++) { if (set2.find(*it) != set2.end()) { result.insert(*it); } } return result; }
bool findDfsVertexPathMarkingRec(vector<Vertex*> &path, const Vertex *end) { Vertex *lastVert = path.back(); if (lastVert == end) return true; if (mEdges.find(lastVert) != mEdges.end()) { VertSet *nexts = mEdges.at(lastVert); for (VertSet::iterator it = nexts->begin(); it != nexts->end(); ++it) { Vertex *vert = *it; if (mMarks.find(vert) == mMarks.end()) { mMarks.insert(vert); path.push_back(vert); bool found = findDfsVertexPathMarkingRec(path, end); if ( found ) return found; else path.pop_back(); } } } return false; }
bool findDfsVertexPathRec(vector<Vertex*> &path, const Vertex *end) const { Vertex *lastVert = path.back(); if (lastVert == end) return true; if (mEdges.find(lastVert) != mEdges.end()) { VertSet *nexts = mEdges.at(lastVert); for (auto it = nexts->begin(); it != nexts->end(); ++it) { path.push_back(*it); bool found = findDfsVertexPathRec(path, end); if ( found ) return found; else path.pop_back(); } } return false; }