COIN-OR::LEMON - Graph Library

Changeset 1283:fc20371677b9 in lemon-0.x for src/lemon/bfs.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/bfs.h

    r1270 r1283  
    654654    ///@{
    655655
     656    ///Copies the shortest path to \c t into \c p
     657   
     658    ///This function copies the shortest path to \c t into \c p.
     659    ///If it \c \t is a source itself or unreachable, then it does not
     660    ///alter \c p.
     661    ///\todo Is it the right way to handle unreachable nodes?
     662    ///\return Returns \c true if a path to \c t was actually copied to \c p,
     663    ///\c false otherwise.
     664    ///\sa DirPath
     665    template<class P>
     666    bool getPath(P &p,Node t)
     667    {
     668      if(reached(t)) {
     669        p.clear();
     670        typename P::Builder b(p);
     671        for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
     672          b.pushFront(pred(t));
     673        b.commit();
     674        return true;
     675      }
     676      return false;
     677    }
     678
    656679    ///The distance of a node from the root(s).
    657680
Note: See TracChangeset for help on using the changeset viewer.