Move the to == from test, so as to return as soon as we find a path. The

old way, we can waste time.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31916 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-11-09 03:53:20 +00:00
parent ac6a58071e
commit 1571887511

View File

@ -154,10 +154,6 @@ Graph::EdgePath const Graph::getPath(int from, int to)
while (!Q_.empty()) {
int const current = Q_.front();
Q_.pop();
if (current == to) {
found = true;
break;
}
vector<OutEdge>::const_iterator const beg =
vertices_[current].out_arrows.begin();
@ -170,9 +166,15 @@ Graph::EdgePath const Graph::getPath(int from, int to)
visited_[cv] = true;
Q_.push(cv);
// FIXME This will not do for finding multiple paths.
// Perhaps we need a vector, or a set.
// Perhaps we need a vector, or a set. We'll also want
// to add this info, even if the node is visited, so
// outside this conditional.
prev[cv] = pair<int, int>(current, cit->edge);
}
if (cv == to) {
found = true;
break;
}
}
}
if (!found)