Changeset 2386:81b47fc5c444 in lemon-0.x for lemon/bellman_ford.h
- Timestamp:
- 03/02/07 19:04:28 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3217
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bellman_ford.h
r2376 r2386 437 437 /// paths. 438 438 bool processNextRound() { 439 for (int i = 0; i < (int)_process.size(); ++i) {439 for (int i = 0; i < int(_process.size()); ++i) { 440 440 _mask->set(_process[i], false); 441 441 } 442 442 std::vector<Node> nextProcess; 443 443 std::vector<Value> values(_process.size()); 444 for (int i = 0; i < (int)_process.size(); ++i) {444 for (int i = 0; i < int(_process.size()); ++i) { 445 445 values[i] = (*_dist)[_process[i]]; 446 446 } 447 for (int i = 0; i < (int)_process.size(); ++i) {447 for (int i = 0; i < int(_process.size()); ++i) { 448 448 for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) { 449 449 Node target = graph->target(it); … … 473 473 /// \return %True when the algorithm have not found more shorter paths. 474 474 bool processNextWeakRound() { 475 for (int i = 0; i < (int)_process.size(); ++i) {475 for (int i = 0; i < int(_process.size()); ++i) { 476 476 _mask->set(_process[i], false); 477 477 } 478 478 std::vector<Node> nextProcess; 479 for (int i = 0; i < (int)_process.size(); ++i) {479 for (int i = 0; i < int(_process.size()); ++i) { 480 480 for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) { 481 481 Node target = graph->target(it); … … 646 646 647 647 bool operator==(const ActiveIt& it) const { 648 return (Node)(*this) == (Node)it;648 return static_cast<Node>(*this) == static_cast<Node>(it); 649 649 } 650 650 bool operator!=(const ActiveIt& it) const { 651 return (Node)(*this) != (Node)it;651 return static_cast<Node>(*this) != static_cast<Node>(it); 652 652 } 653 653 bool operator<(const ActiveIt& it) const { 654 return (Node)(*this) < (Node)it;654 return static_cast<Node>(*this) < static_cast<Node>(it); 655 655 } 656 656 … … 866 866 const _LengthMap& length, 867 867 Node source = INVALID) : 868 _graph((void *)&graph), _length((void *)&length), _pred(0), 869 _dist(0), _source(source) {} 868 _graph(reinterpret_cast<void*>(const_cast<_Graph*>(&graph))), 869 _length(reinterpret_cast<void*>(const_cast<_LengthMap*>(&length))), 870 _pred(0), _dist(0), _source(source) {} 870 871 871 872 }; … … 924 925 /// These parameters will be the default values for the traits class. 925 926 BellmanFordWizard(const Graph& graph, const LengthMap& length, 926 Node s ource= INVALID)927 : _Traits(graph, length, s ource) {}927 Node src = INVALID) 928 : _Traits(graph, length, src) {} 928 929 929 930 /// \brief Copy constructor … … 939 940 if(Base::_source == INVALID) throw UninitializedParameter(); 940 941 BellmanFord<Graph,LengthMap,_Traits> 941 bf(*(Graph*)Base::_graph, *(LengthMap*)Base::_length); 942 if (Base::_pred) bf.predMap(*(PredMap*)Base::_pred); 943 if (Base::_dist) bf.distMap(*(DistMap*)Base::_dist); 942 bf(*reinterpret_cast<const Graph*>(Base::_graph), 943 *reinterpret_cast<const LengthMap*>(Base::_length)); 944 if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 945 if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 944 946 bf.run(Base::_source); 945 947 } … … 949 951 /// Runs BellmanFord algorithm from the given node. 950 952 /// \param source is the given source. 951 void run(Node s ource) {952 Base::_source = s ource;953 void run(Node src) { 954 Base::_source = src; 953 955 run(); 954 956 } … … 970 972 BellmanFordWizard<DefPredMapBase<T> > predMap(const T &t) 971 973 { 972 Base::_pred= (void *)&t;974 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 973 975 return BellmanFordWizard<DefPredMapBase<T> >(*this); 974 976 } … … 989 991 template<class T> 990 992 BellmanFordWizard<DefDistMapBase<T> > distMap(const T &t) { 991 Base::_dist= (void *)&t;993 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); 992 994 return BellmanFordWizard<DefDistMapBase<T> >(*this); 993 995 } … … 1014 1016 /// Sets the source node, from which the BellmanFord algorithm runs. 1015 1017 /// \param source is the source node. 1016 BellmanFordWizard<_Traits>& source(Node s ource) {1017 Base::_source = s ource;1018 BellmanFordWizard<_Traits>& source(Node src) { 1019 Base::_source = src; 1018 1020 return *this; 1019 1021 }
Note: See TracChangeset
for help on using the changeset viewer.