lemon/dfs.h
changeset 2439 3f1c7a6c33cd
parent 2391 14a343be7a5a
child 2443 14abfa02bf42
     1.1 --- a/lemon/dfs.h	Mon May 07 08:48:40 2007 +0000
     1.2 +++ b/lemon/dfs.h	Mon May 07 08:49:57 2007 +0000
     1.3 @@ -564,14 +564,19 @@
     1.4      ///with addSource() before using this function.
     1.5      ///
     1.6      ///\param em must be a bool (or convertible) edge map. The algorithm
     1.7 -    ///will stop when it reaches an edge \c e with \code em[e]==true \endcode.
     1.8 +    ///will stop when it reaches an edge \c e with <tt>em[e]==true<\tt>.
     1.9      ///
    1.10 -    ///\warning Contrary to \ref Dfs and \ref Dijkstra, \c em is an edge map,
    1.11 +    ///\return The reached edge \c e with <tt>em[e]==true<\tt> or
    1.12 +    ///\c INVALID if no such edge was found.
    1.13 +    ///
    1.14 +    ///\warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an edge map,
    1.15      ///not a node map.
    1.16      template<class EM>
    1.17 -    void start(const EM &em)
    1.18 +    Edge start(const EM &em)
    1.19      {
    1.20 -      while ( !emptyQueue() && !em[_stack[_stack_head]] ) processNextEdge();
    1.21 +      while ( !emptyQueue() && !em[_stack[_stack_head]] )
    1.22 +        processNextEdge();
    1.23 +      return emptyQueue() ? INVALID : _stack[_stack_head];
    1.24      }
    1.25  
    1.26      ///Runs %DFS algorithm to visit all nodes in the graph.
    1.27 @@ -1441,7 +1446,7 @@
    1.28      /// \pre init() must be called and at least one node should be added
    1.29      /// with addSource() before using this function.
    1.30      void start(Node dest) {
    1.31 -      while ( !emptyQueue() && _graph->target(_stack[_stack_head]) != dest) 
    1.32 +      while ( !emptyQueue() && _graph->target(_stack[_stack_head]) != dest ) 
    1.33  	processNextEdge();
    1.34      }
    1.35      
    1.36 @@ -1453,13 +1458,18 @@
    1.37      /// with addSource() before using this function.
    1.38      ///
    1.39      /// \param em must be a bool (or convertible) edge map. The algorithm
    1.40 -    /// will stop when it reaches an edge \c e with \code nm[e]==true \endcode.
    1.41 +    /// will stop when it reaches an edge \c e with <tt>em[e]==true<\tt>.
    1.42      ///
    1.43 -    /// \warning Contrary to \ref Dfs and \ref Dijkstra, \c em is an edge map,
    1.44 +    ///\return The reached edge \c e with <tt>em[e]==true<\tt> or
    1.45 +    ///\c INVALID if no such edge was found.
    1.46 +    ///
    1.47 +    /// \warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an edge map,
    1.48      /// not a node map.
    1.49      template <typename EM>
    1.50 -    void start(const EM &em) {
    1.51 -      while (!emptyQueue() && !em[_stack[_stack_head]]) processNextEdge();
    1.52 +    Edge start(const EM &em) {
    1.53 +      while ( !emptyQueue() && !em[_stack[_stack_head]] )
    1.54 +        processNextEdge();
    1.55 +      return emptyQueue() ? INVALID : _stack[_stack_head];
    1.56      }
    1.57  
    1.58      /// \brief Runs %DFSVisit algorithm from node \c s.