Merge bugfix #392 to branch 1.0 1.0
authorAlpar Juttner <alpar@cs.elte.hu>
Wed, 22 Sep 2010 09:24:07 +0200
branch1.0
changeset 421b7ed95cd94a3
parent 419 66aafc8c62d6
parent 420 e24922c56bc2
child 423 e8afd887d706
Merge bugfix #392 to branch 1.0
lemon/dfs.h
     1.1 --- a/lemon/dfs.h	Tue Sep 21 06:19:04 2010 +0200
     1.2 +++ b/lemon/dfs.h	Wed Sep 22 09:24:07 2010 +0200
     1.3 @@ -558,7 +558,7 @@
     1.4      ///added with addSource() before using this function.
     1.5      void start(Node t)
     1.6      {
     1.7 -      while ( !emptyQueue() && G->target(_stack[_stack_head])!=t )
     1.8 +      while ( !emptyQueue() && !(*_reached)[t] )
     1.9          processNextArc();
    1.10      }
    1.11  
    1.12 @@ -1512,7 +1512,7 @@
    1.13      /// \pre init() must be called and a root node should be added
    1.14      /// with addSource() before using this function.
    1.15      void start(Node t) {
    1.16 -      while ( !emptyQueue() && _digraph->target(_stack[_stack_head]) != t )
    1.17 +      while ( !emptyQueue() && !(*_reached)[t] )
    1.18          processNextArc();
    1.19      }
    1.20  
     2.1 --- a/test/dfs_test.cc	Tue Sep 21 06:19:04 2010 +0200
     2.2 +++ b/test/dfs_test.cc	Wed Sep 22 09:24:07 2010 +0200
     2.3 @@ -50,7 +50,10 @@
     2.4    "6 3  7\n"
     2.5    "@attributes\n"
     2.6    "source 0\n"
     2.7 -  "target 5\n";
     2.8 +  "target 5\n"
     2.9 +  "source1 6\n"
    2.10 +  "target1 3\n";
    2.11 +
    2.12  
    2.13  void checkDfsCompile()
    2.14  {
    2.15 @@ -144,11 +147,14 @@
    2.16  
    2.17    Digraph G;
    2.18    Node s, t;
    2.19 +  Node s1, t1;
    2.20  
    2.21    std::istringstream input(test_lgf);
    2.22    digraphReader(G, input).
    2.23      node("source", s).
    2.24      node("target", t).
    2.25 +    node("source1", s1).
    2.26 +    node("target1", t1).
    2.27      run();
    2.28  
    2.29    Dfs<Digraph> dfs_test(G);
    2.30 @@ -175,6 +181,11 @@
    2.31    }
    2.32  
    2.33    {
    2.34 +  Dfs<Digraph> dfs(G);
    2.35 +  check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6.");
    2.36 +  }
    2.37 +  
    2.38 +  {
    2.39      NullMap<Node,Arc> myPredMap;
    2.40      dfs(G).predMap(myPredMap).run(s);
    2.41    }