COIN-OR::LEMON - Graph Library

Changeset 1283:fc20371677b9 in lemon-0.x for src/lemon/dfs.h


Ignore:
Timestamp:
03/31/05 15:31:39 (16 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1715
Message:

getPath() added to Bfs/Dfs/Dijkstra?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/dfs.h

    r1236 r1283  
    661661    ///@{
    662662
     663    ///Copies the path to \c t on the DFS tree into \c p
     664   
     665    ///This function copies the path on the DFS tree to \c t into \c p.
     666    ///If it \c \t is a source itself or unreachable, then it does not
     667    ///alter \c p.
     668    ///\todo Is it the right way to handle unreachable nodes?
     669    ///\return Returns \c true if a path to \c t was actually copied to \c p,
     670    ///\c false otherwise.
     671    ///\sa DirPath
     672    template<class P>
     673    bool getPath(P &p,Node t)
     674    {
     675      if(reached(t)) {
     676        p.clear();
     677        typename P::Builder b(p);
     678        for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
     679          b.pushFront(pred(t));
     680        b.commit();
     681        return true;
     682      }
     683      return false;
     684    }
     685
    663686    ///The distance of a node from the root(s).
    664687
Note: See TracChangeset for help on using the changeset viewer.