# HG changeset patch # User alpar # Date 1111405208 0 # Node ID f3d856bf1ebfd5675df27731b6975a264b78b575 # Parent 43fc017da4f80f8ff788ecf3cbbadf13760dc3bf Several serious bugs fixed diff -r 43fc017da4f8 -r f3d856bf1ebf src/lemon/dfs.h --- a/src/lemon/dfs.h Mon Mar 21 11:08:17 2005 +0000 +++ b/src/lemon/dfs.h Mon Mar 21 11:40:08 2005 +0000 @@ -525,7 +525,8 @@ _pred->set(m,e); _reached->set(m,true); // _pred_node->set(m,G->source(e)); - _stack[++_stack_head] = OutEdgeIt(*G, m); + ++_stack_head; + _stack[_stack_head] = OutEdgeIt(*G, m); _dist->set(m,_stack_head); } else { @@ -587,7 +588,8 @@ /// void start(Node dest) { - while ( !emptyQueue() && _queue[_queue_tail]!=dest ) processNextEdge(); + while ( !emptyQueue() && G->target(_stack[_stack_head])!=dest ) + processNextEdge(); } ///Executes the algorithm until a condition is met. @@ -597,12 +599,14 @@ ///\pre init() must be called and at least one node should be added ///with addSource() before using this function. /// - ///\param nm must be a bool (or convertible) node map. The algorithm - ///will stop when it reaches a node \c v with nm[v]==true. + ///\param nm must be a bool (or convertible) edge map. The algorithm + ///will stop when it reaches a edge \c v with nm[v]==true. + ///\warning Contrary to \ref Dfs and \ref Dijkstra, \c mn is an edge map, + ///not a node map. template void start(const NM &nm) { - while ( !emptyQueue() && !nm[_queue[_queue_tail]] ) processNextEdge(); + while ( !emptyQueue() && !nm[_stack[_stack_head]] ) processNextEdge(); } ///Runs %DFS algorithm from node \c s. @@ -643,7 +647,7 @@ init(); addSource(s); start(t); - return reached(t)?_curr_dist-1+(_queue_tail==_queue_next_dist):0; + return reached(t)?_stack_head+1:0; } ///@} diff -r 43fc017da4f8 -r f3d856bf1ebf src/test/dfs_test.cc --- a/src/test/dfs_test.cc Mon Mar 21 11:08:17 2005 +0000 +++ b/src/test/dfs_test.cc Mon Mar 21 11:40:08 2005 +0000 @@ -109,7 +109,8 @@ Node u=G.source(e); check(u==dfs_test.predNode(v),"Wrong tree."); check(dfs_test.dist(v) - dfs_test.dist(u) == 1, - "Wrong distance." << dfs_test.dist(v) << " " <" + <