COIN-OR::LEMON - Graph Library

Changeset 1710:f531c16dd923 in lemon-0.x for lemon/belmann_ford.h


Ignore:
Timestamp:
10/06/05 11:37:53 (15 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2237
Message:

Bug solved in named parameters
Simplify my Johnson algorithm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/belmann_ford.h

    r1699 r1710  
    168168  /// \author Balazs Dezso
    169169
     170#ifdef DOXYGEN
     171  template <typename _Graph, typename _LengthMap, typename _Traits>
     172#else
    170173  template <typename _Graph=ListGraph,
    171174            typename _LengthMap=typename _Graph::template EdgeMap<int>,
    172175            typename _Traits=BelmannFordDefaultTraits<_Graph,_LengthMap> >
     176#endif
    173177  class BelmannFord {
    174178  public:
     
    234238  public :
    235239 
     240    typedef BelmannFord Create;
     241
    236242    /// \name Named template parameters
    237243
     
    241247    struct DefPredMapTraits : public Traits {
    242248      typedef T PredMap;
    243       static PredMap *createPredMap(const Graph& graph) {
     249      static PredMap *createPredMap(const Graph&) {
    244250        throw UninitializedParameter();
    245251      }
     
    251257    ///
    252258    template <class T>
    253     class DefPredMap
    254       : public BelmannFord< Graph, LengthMap, DefPredMapTraits<T> > {};
     259    struct DefPredMap {
     260      typedef BelmannFord< Graph, LengthMap, DefPredMapTraits<T> > Create;
     261    };
    255262   
    256263    template <class T>
     
    268275    ///
    269276    template <class T>
    270     class DefDistMap
    271       : public BelmannFord< Graph, LengthMap, DefDistMapTraits<T> > {};
     277    struct DefDistMap
     278      : public BelmannFord< Graph, LengthMap, DefDistMapTraits<T> > {
     279      typedef BelmannFord< Graph, LengthMap, DefDistMapTraits<T> > Create;
     280    };
    272281   
    273282    template <class T>
     
    279288    /// OperationTraits type
    280289    ///
    281     /// \ref named-templ-param "Named parameter" for setting PredMap type
     290    /// \ref named-templ-param "Named parameter" for setting OperationTraits
     291    /// type
    282292    template <class T>
    283     class DefOperationTraits
     293    struct DefOperationTraits
    284294      : public BelmannFord< Graph, LengthMap, DefOperationTraitsTraits<T> > {
    285     public:
    286295      typedef BelmannFord< Graph, LengthMap, DefOperationTraitsTraits<T> >
    287       BelmannFord;
     296      Create;
    288297    };
    289298   
    290299    ///@}
     300
     301  protected:
     302   
     303    BelmannFord() {}
    291304
    292305  public:     
     
    363376    ///
    364377    /// Initializes the internal data structures.
    365     void init() {
     378    void init(const Value value = OperationTraits::infinity()) {
    366379      create_maps();
    367380      for (NodeIt it(*graph); it != INVALID; ++it) {
    368381        _pred->set(it, INVALID);
    369         _dist->set(it, OperationTraits::infinity());
     382        _dist->set(it, value);
    370383      }
    371384    }
     
    741754      return BelmannFordWizard<DefDistMapBase<T> >(*this);
    742755    }
     756
     757    template<class T>
     758    struct DefOperationTraitsBase : public Base {
     759      typedef T OperationTraits;
     760      DefOperationTraitsBase(const _Traits &b) : _Traits(b) {}
     761    };
     762   
     763    ///\brief \ref named-templ-param "Named parameter"
     764    ///function for setting OperationTraits type
     765    ///
     766    /// \ref named-templ-param "Named parameter"
     767    ///function for setting OperationTraits type
     768    ///
     769    template<class T>
     770    BelmannFordWizard<DefOperationTraitsBase<T> > distMap() {
     771      return BelmannFordWizard<DefDistMapBase<T> >(*this);
     772    }
    743773   
    744774    /// \brief Sets the source node, from which the BelmannFord algorithm runs.
Note: See TracChangeset for help on using the changeset viewer.