COIN-OR::LEMON - Graph Library

Changeset 2439:3f1c7a6c33cd in lemon-0.x for lemon/dfs.h


Ignore:
Timestamp:
05/07/07 10:49:57 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3276
Message:

Modified start() function in Dfs and Dijkstra classes to give back reached
edge/node.

Patch from Peter Kovacs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/dfs.h

    r2391 r2439  
    565565    ///
    566566    ///\param em must be a bool (or convertible) edge map. The algorithm
    567     ///will stop when it reaches an edge \c e with \code em[e]==true \endcode.
    568     ///
    569     ///\warning Contrary to \ref Dfs and \ref Dijkstra, \c em is an edge map,
     567    ///will stop when it reaches an edge \c e with <tt>em[e]==true<\tt>.
     568    ///
     569    ///\return The reached edge \c e with <tt>em[e]==true<\tt> or
     570    ///\c INVALID if no such edge was found.
     571    ///
     572    ///\warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an edge map,
    570573    ///not a node map.
    571574    template<class EM>
    572     void start(const EM &em)
    573     {
    574       while ( !emptyQueue() && !em[_stack[_stack_head]] ) processNextEdge();
     575    Edge start(const EM &em)
     576    {
     577      while ( !emptyQueue() && !em[_stack[_stack_head]] )
     578        processNextEdge();
     579      return emptyQueue() ? INVALID : _stack[_stack_head];
    575580    }
    576581
     
    14421447    /// with addSource() before using this function.
    14431448    void start(Node dest) {
    1444       while ( !emptyQueue() && _graph->target(_stack[_stack_head]) != dest)
     1449      while ( !emptyQueue() && _graph->target(_stack[_stack_head]) != dest )
    14451450        processNextEdge();
    14461451    }
     
    14541459    ///
    14551460    /// \param em must be a bool (or convertible) edge map. The algorithm
    1456     /// will stop when it reaches an edge \c e with \code nm[e]==true \endcode.
    1457     ///
    1458     /// \warning Contrary to \ref Dfs and \ref Dijkstra, \c em is an edge map,
     1461    /// will stop when it reaches an edge \c e with <tt>em[e]==true<\tt>.
     1462    ///
     1463    ///\return The reached edge \c e with <tt>em[e]==true<\tt> or
     1464    ///\c INVALID if no such edge was found.
     1465    ///
     1466    /// \warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an edge map,
    14591467    /// not a node map.
    14601468    template <typename EM>
    1461     void start(const EM &em) {
    1462       while (!emptyQueue() && !em[_stack[_stack_head]]) processNextEdge();
     1469    Edge start(const EM &em) {
     1470      while ( !emptyQueue() && !em[_stack[_stack_head]] )
     1471        processNextEdge();
     1472      return emptyQueue() ? INVALID : _stack[_stack_head];
    14631473    }
    14641474
Note: See TracChangeset for help on using the changeset viewer.