COIN-OR::LEMON - Graph Library

Changeset 2335:27aa03cd3121 in lemon-0.x for lemon/bfs.h


Ignore:
Timestamp:
01/08/07 11:39:59 (13 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3123
Message:

New path concept and path structures

TODO: BellmanFord::negativeCycle()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bfs.h

    r2307 r2335  
    2626#include <lemon/list_graph.h>
    2727#include <lemon/graph_utils.h>
     28#include <lemon/bits/path_dump.h>
    2829#include <lemon/bits/invalid.h>
    2930#include <lemon/error.h>
     
    677678    ///@{
    678679
    679     ///Copies the shortest path to \c t into \c p
    680    
    681     ///This function copies the shortest path to \c t into \c p.
    682     ///If \c t is a source itself or unreachable, then it does not
    683     ///alter \c p.
    684     ///\return Returns \c true if a path to \c t was actually copied to \c p,
    685     ///\c false otherwise.
    686     ///\sa DirPath
    687     template<class P>
    688     bool getPath(P &p,Node t)
    689     {
    690       if(reached(t)) {
    691         p.clear();
    692         typename P::Builder b(p);
    693         for(b.setStartNode(t);predEdge(t)!=INVALID;t=predNode(t))
    694           b.pushFront(predEdge(t));
    695         b.commit();
    696         return true;
    697       }
    698       return false;
     680    typedef PredMapPath<Graph, PredMap> Path;
     681
     682    ///Gives back the shortest path.
     683   
     684    ///Gives back the shortest path.
     685    ///\pre The \c t should be reachable from the source.
     686    Path path(Node t)
     687    {
     688      return Path(*G, *_pred, t);
    699689    }
    700690
Note: See TracChangeset for help on using the changeset viewer.