1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

directed-graph: fix bug in loop detection

This commit is contained in:
Daniel Krebs 2018-02-07 10:22:35 +01:00
parent 32be16ef98
commit 6dab50824b

View file

@ -204,13 +204,13 @@ public:
auto fromVertex = getVertex(fromVertexId);
for(auto& edgeId : fromVertex->edges) {
auto edge = getEdge(edgeId);
auto edgeOfFromVertex = getEdge(edgeId);
// loop detection
bool loop = false;
for(auto& edgeIdInPath : path) {
auto edgeInPath = getEdge(edgeIdInPath);
if(edgeInPath->from == edgeId) {
if(edgeInPath->from == edgeOfFromVertex->to) {
loop = true;
break;
}
@ -225,7 +225,7 @@ public:
path.push_back(edgeId);
// recursive, depth-first search
if(getPath(edge->to, toVertexId, path)) {
if(getPath(edgeOfFromVertex->to, toVertexId, path)) {
// path found, we're done
return true;
} else {