Changeset 1233:f3d856bf1ebf in lemon-0.x
- Timestamp:
- 03/21/05 12:40:08 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1660
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/lemon/dfs.h
r1220 r1233 526 526 _reached->set(m,true); 527 527 // _pred_node->set(m,G->source(e)); 528 _stack[++_stack_head] = OutEdgeIt(*G, m); 528 ++_stack_head; 529 _stack[_stack_head] = OutEdgeIt(*G, m); 529 530 _dist->set(m,_stack_head); 530 531 } … … 588 589 void start(Node dest) 589 590 { 590 while ( !emptyQueue() && _queue[_queue_tail]!=dest ) processNextEdge(); 591 while ( !emptyQueue() && G->target(_stack[_stack_head])!=dest ) 592 processNextEdge(); 591 593 } 592 594 … … 598 600 ///with addSource() before using this function. 599 601 /// 600 ///\param nm must be a bool (or convertible) node map. The algorithm 601 ///will stop when it reaches a node \c v with <tt>nm[v]==true</tt>. 602 ///\param nm must be a bool (or convertible) edge map. The algorithm 603 ///will stop when it reaches a edge \c v with <tt>nm[v]==true</tt>. 604 ///\warning Contrary to \ref Dfs and \ref Dijkstra, \c mn is an edge map, 605 ///not a node map. 602 606 template<class NM> 603 607 void start(const NM &nm) 604 608 { 605 while ( !emptyQueue() && !nm[_ queue[_queue_tail]] ) processNextEdge();609 while ( !emptyQueue() && !nm[_stack[_stack_head]] ) processNextEdge(); 606 610 } 607 611 … … 644 648 addSource(s); 645 649 start(t); 646 return reached(t)?_ curr_dist-1+(_queue_tail==_queue_next_dist):0;650 return reached(t)?_stack_head+1:0; 647 651 } 648 652 -
src/test/dfs_test.cc
r1220 r1233 110 110 check(u==dfs_test.predNode(v),"Wrong tree."); 111 111 check(dfs_test.dist(v) - dfs_test.dist(u) == 1, 112 "Wrong distance." << dfs_test.dist(v) << " " <<dfs_test.dist(u) ); 112 "Wrong distance. (" << dfs_test.dist(u) << "->" 113 <<dfs_test.dist(v) << ')'); 113 114 } 114 115 }
Note: See TracChangeset
for help on using the changeset viewer.