# HG changeset patch # User Alpar Juttner # Date 1285140247 -7200 # Node ID b7ed95cd94a38e4c7f075df200f692cd267c8a46 # Parent 66aafc8c62d6af14858f0307ef418020d91ffd70# Parent e24922c56bc2e6cef6cff65c251ce6000005d00f Merge bugfix #392 to branch 1.0 diff -r 66aafc8c62d6 -r b7ed95cd94a3 lemon/dfs.h --- a/lemon/dfs.h Tue Sep 21 06:19:04 2010 +0200 +++ b/lemon/dfs.h Wed Sep 22 09:24:07 2010 +0200 @@ -558,7 +558,7 @@ ///added with addSource() before using this function. void start(Node t) { - while ( !emptyQueue() && G->target(_stack[_stack_head])!=t ) + while ( !emptyQueue() && !(*_reached)[t] ) processNextArc(); } @@ -1512,7 +1512,7 @@ /// \pre init() must be called and a root node should be added /// with addSource() before using this function. void start(Node t) { - while ( !emptyQueue() && _digraph->target(_stack[_stack_head]) != t ) + while ( !emptyQueue() && !(*_reached)[t] ) processNextArc(); } diff -r 66aafc8c62d6 -r b7ed95cd94a3 test/dfs_test.cc --- a/test/dfs_test.cc Tue Sep 21 06:19:04 2010 +0200 +++ b/test/dfs_test.cc Wed Sep 22 09:24:07 2010 +0200 @@ -50,7 +50,10 @@ "6 3 7\n" "@attributes\n" "source 0\n" - "target 5\n"; + "target 5\n" + "source1 6\n" + "target1 3\n"; + void checkDfsCompile() { @@ -144,11 +147,14 @@ Digraph G; Node s, t; + Node s1, t1; std::istringstream input(test_lgf); digraphReader(G, input). node("source", s). node("target", t). + node("source1", s1). + node("target1", t1). run(); Dfs dfs_test(G); @@ -175,6 +181,11 @@ } { + Dfs dfs(G); + check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6."); + } + + { NullMap myPredMap; dfs(G).predMap(myPredMap).run(s); }