# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1285138389 -7200
# Node ID e24922c56bc2e6cef6cff65c251ce6000005d00f
# Parent  bb871cb8ac0664d5db95721a1d678d604762a3c2
Bug fix in Dfs::start(s,t) (#392)

diff -r bb871cb8ac06 -r e24922c56bc2 lemon/dfs.h
--- a/lemon/dfs.h	Tue Jun 22 15:39:26 2010 +0200
+++ b/lemon/dfs.h	Wed Sep 22 08:53:09 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();
     }
 
@@ -1511,7 +1511,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 bb871cb8ac06 -r e24922c56bc2 test/dfs_test.cc
--- a/test/dfs_test.cc	Tue Jun 22 15:39:26 2010 +0200
+++ b/test/dfs_test.cc	Wed Sep 22 08:53:09 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<Digraph> dfs_test(G);
@@ -175,6 +181,11 @@
   }
 
   {
+  Dfs<Digraph> dfs(G);
+  check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6.");
+  }
+  
+  {
     NullMap<Node,Arc> myPredMap;
     dfs(G).predMap(myPredMap).run(s);
   }