COIN-OR::LEMON - Graph Library

Changeset 1709:a323456bf7c8 in lemon-0.x for lemon/bfs.h


Ignore:
Timestamp:
10/05/05 18:45:37 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2236
Message:

Template Named Parameter bugfix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bfs.h

    r1694 r1709  
    5858      return new PredMap(G);
    5959    }
    60 //     ///\brief The type of the map that stores the last but one
    61 //     ///nodes of the shortest paths.
    62 //     ///
    63 //     ///The type of the map that stores the last but one
    64 //     ///nodes of the shortest paths.
    65 //     ///It must meet the \ref concept::WriteMap "WriteMap" concept.
    66 //     ///
    67 //     typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
    68 //     ///Instantiates a PredNodeMap.
    69    
    70 //     ///This function instantiates a \ref PredNodeMap.
    71 //     ///\param G is the graph, to which
    72 //     ///we would like to define the \ref PredNodeMap
    73 //     static PredNodeMap *createPredNodeMap(const GR &G)
    74 //     {
    75 //       return new PredNodeMap();
    76 //     }
    77 
    7860    ///The type of the map that indicates which nodes are processed.
    7961 
     
    180162    ///edges of the shortest paths.
    181163    typedef typename TR::PredMap PredMap;
    182 //     ///\brief The type of the map that stores the last but one
    183 //     ///nodes of the shortest paths.
    184 //     typedef typename TR::PredNodeMap PredNodeMap;
    185164    ///The type of the map indicating which nodes are reached.
    186165    typedef typename TR::ReachedMap ReachedMap;
     
    196175    ///Indicates if \ref _pred is locally allocated (\c true) or not.
    197176    bool local_pred;
    198 //     ///Pointer to the map of predecessors nodes.
    199 //     PredNodeMap *_predNode;
    200 //     ///Indicates if \ref _predNode is locally allocated (\c true) or not.
    201 //     bool local_predNode;
    202177    ///Pointer to the map of distances.
    203178    DistMap *_dist;
     
    216191    int _queue_head,_queue_tail,_queue_next_dist;
    217192    int _curr_dist;
    218 //     ///The source node of the last execution.
    219 //     Node source;
    220193
    221194    ///Creates the maps if necessary.
     
    229202        _pred = Traits::createPredMap(*G);
    230203      }
    231 //       if(!_predNode) {
    232 //      local_predNode = true;
    233 //      _predNode = Traits::createPredNodeMap(*G);
    234 //       }
    235204      if(!_dist) {
    236205        local_dist = true;
     
    266235    ///
    267236    template <class T>
    268     class DefPredMap : public Bfs< Graph, DefPredMapTraits<T> > { };
    269    
    270 //     template <class T>
    271 //     struct DefPredNodeMapTraits : public Traits {
    272 //       typedef T PredNodeMap;
    273 //       static PredNodeMap *createPredNodeMap(const Graph &G)
    274 //       {
    275 //      throw UninitializedParameter();
    276 //       }
    277 //     };
    278 //     ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
    279 
    280 //     ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
    281 //     ///
    282 //     template <class T>
    283 //     class DefPredNodeMap : public Bfs< Graph,
    284 //                                          LengthMap,
    285 //                                          DefPredNodeMapTraits<T> > { };
     237    struct DefPredMap : public Bfs< Graph, DefPredMapTraits<T> > {
     238      typedef Bfs< Graph, DefPredMapTraits<T> > Create;
     239    };
    286240   
    287241    template <class T>
     
    298252    ///
    299253    template <class T>
    300     class DefDistMap : public Bfs< Graph,
    301                                    DefDistMapTraits<T> > { };
     254    struct DefDistMap : public Bfs< Graph, DefDistMapTraits<T> > {
     255      typedef Bfs< Graph, DefDistMapTraits<T> > Create;
     256    };
    302257   
    303258    template <class T>
     
    314269    ///
    315270    template <class T>
    316     class DefReachedMap : public Bfs< Graph,
    317                                       DefReachedMapTraits<T> > { };
    318    
    319     struct DefGraphReachedMapTraits : public Traits {
    320       typedef typename Graph::template NodeMap<bool> ReachedMap;
    321       static ReachedMap *createReachedMap(const Graph &G)
    322       {
    323         return new ReachedMap(G);
    324       }
    325     };
     271    struct DefReachedMap : public Bfs< Graph, DefReachedMapTraits<T> > {
     272      typedef Bfs< Graph, DefReachedMapTraits<T> > Create;
     273    };
     274   
    326275    template <class T>
    327276    struct DefProcessedMapTraits : public Traits {
     
    337286    ///
    338287    template <class T>
    339     class DefProcessedMap : public Bfs< Graph,
    340                                         DefProcessedMapTraits<T> > { };
     288    struct DefProcessedMap : public Bfs< Graph, DefProcessedMapTraits<T> > {
     289      typedef Bfs< Graph, DefProcessedMapTraits<T> > Create;
     290    };
    341291   
    342292    struct DefGraphProcessedMapTraits : public Traits {
     
    354304    ///If you don't set it explicitly, it will be automatically allocated.
    355305    template <class T>
    356     class DefProcessedMapToBeDefaultMap :
    357       public Bfs< Graph,
    358                   DefGraphProcessedMapTraits> { };
     306    struct DefProcessedMapToBeDefaultMap :
     307      public Bfs< Graph, DefGraphProcessedMapTraits> {
     308      typedef Bfs< Graph, DefGraphProcessedMapTraits> Create;
     309    };
    359310   
    360311    ///@}
     
    369320      G(&_G),
    370321      _pred(NULL), local_pred(false),
    371 //       _predNode(NULL), local_predNode(false),
    372322      _dist(NULL), local_dist(false),
    373323      _reached(NULL), local_reached(false),
     
    379329    {
    380330      if(local_pred) delete _pred;
    381 //       if(local_predNode) delete _predNode;
    382331      if(local_dist) delete _dist;
    383332      if(local_reached) delete _reached;
     
    435384      return *this;
    436385    }
    437 
    438 //     ///Sets the map storing the predecessor nodes.
    439 
    440 //     ///Sets the map storing the predecessor nodes.
    441 //     ///If you don't use this function before calling \ref run(),
    442 //     ///it will allocate one. The destructor deallocates this
    443 //     ///automatically allocated map, of course.
    444 //     ///\return <tt> (*this) </tt>
    445 //     Bfs &predNodeMap(PredNodeMap &m)
    446 //     {
    447 //       if(local_predNode) {
    448 //      delete _predNode;
    449 //      local_predNode=false;
    450 //       }
    451 //       _predNode = &m;
    452 //       return *this;
    453 //     }
    454386
    455387    ///Sets the map storing the distances calculated by the algorithm.
     
    495427      for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
    496428        _pred->set(u,INVALID);
    497 //      _predNode->set(u,INVALID);
    498429        _reached->set(u,false);
    499430        _processed->set(u,false);
     
    538469          _reached->set(m,true);
    539470          _pred->set(m,e);
    540 //        _pred_node->set(m,n);
    541471          _dist->set(m,_curr_dist);
    542472        }
     
    746676    const PredMap &predMap() const { return *_pred;}
    747677 
    748 //     ///Returns a reference to the map of nodes of shortest paths.
    749 
    750 //     ///Returns a reference to the NodeMap of the last but one nodes of the
    751 //     ///shortest path tree.
    752 //     ///\pre \ref run() must be called before using this function.
    753 //     const PredNodeMap &predNodeMap() const { return *_predNode;}
    754 
    755678    ///Checks if a node is reachable from the root.
    756679
     
    795718      return new PredMap();
    796719    }
    797 //     ///\brief The type of the map that stores the last but one
    798 //     ///nodes of the shortest paths.
    799 //     ///
    800 //     ///The type of the map that stores the last but one
    801 //     ///nodes of the shortest paths.
    802 //     ///It must meet the \ref concept::WriteMap "WriteMap" concept.
    803 //     ///
    804 //     typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
    805 //     ///Instantiates a PredNodeMap.
    806    
    807 //     ///This function instantiates a \ref PredNodeMap.
    808 //     ///\param G is the graph, to which
    809 //     ///we would like to define the \ref PredNodeMap
    810 //     static PredNodeMap *createPredNodeMap(const GR &G)
    811 //     {
    812 //       return new PredNodeMap();
    813 //     }
    814720
    815721    ///The type of the map that indicates which nodes are processed.
     
    892798    ///Pointer to the map of predecessors edges.
    893799    void *_pred;
    894 //     ///Pointer to the map of predecessors nodes.
    895 //     void *_predNode;
    896800    ///Pointer to the map of distances.
    897801    void *_dist;
     
    905809    /// all of the attributes to default values (0, INVALID).
    906810    BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
    907 //                         _predNode(0),
    908811                           _dist(0), _source(INVALID) {}
    909812
     
    917820    BfsWizardBase(const GR &g, Node s=INVALID) :
    918821      _g((void *)&g), _reached(0), _processed(0), _pred(0),
    919 //       _predNode(0),
    920822      _dist(0), _source(s) {}
    921823
     
    966868    ///edges of the shortest paths.
    967869    typedef typename TR::PredMap PredMap;
    968 //     ///\brief The type of the map that stores the last but one
    969 //     ///nodes of the shortest paths.
    970 //     typedef typename TR::PredNodeMap PredNodeMap;
    971870    ///The type of the map that stores the dists of the nodes.
    972871    typedef typename TR::DistMap DistMap;
     
    1000899      if(Base::_processed) alg.processedMap(*(ProcessedMap*)Base::_processed);
    1001900      if(Base::_pred) alg.predMap(*(PredMap*)Base::_pred);
    1002 //       if(Base::_predNode) alg.predNodeMap(*(PredNodeMap*)Base::_predNode);
    1003901      if(Base::_dist) alg.distMap(*(DistMap*)Base::_dist);
    1004902      alg.run(Base::_source);
     
    1077975    }
    1078976   
    1079 
    1080 //     template<class T>
    1081 //     struct DefPredNodeMapBase : public Base {
    1082 //       typedef T PredNodeMap;
    1083 //       static PredNodeMap *createPredNodeMap(const Graph &G) { return 0; };
    1084 //       DefPredNodeMapBase(const TR &b) : TR(b) {}
    1085 //     };
    1086    
    1087 //     ///\brief \ref named-templ-param "Named parameter"
    1088 //     ///function for setting PredNodeMap type
    1089 //     ///
    1090 //     /// \ref named-templ-param "Named parameter"
    1091 //     ///function for setting PredNodeMap type
    1092 //     ///
    1093 //     template<class T>
    1094 //     BfsWizard<DefPredNodeMapBase<T> > predNodeMap(const T &t)
    1095 //     {
    1096 //       Base::_predNode=(void *)&t;
    1097 //       return BfsWizard<DefPredNodeMapBase<T> >(*this);
    1098 //     }
    1099977   
    1100978    template<class T>
Note: See TracChangeset for help on using the changeset viewer.