Changes in / [834:207ba6c0f2e4:835:b9b2e8abe70b] in lemon-main
- Files:
-
- 4 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
INSTALL
r568 r824 174 174 175 175 Disable COIN-OR support. 176 177 178 Makefile Variables 179 ================== 180 181 Some Makefile variables are reserved by the GNU Coding Standards for 182 the use of the "user" - the person building the package. For instance, 183 CXX and CXXFLAGS are such variables, and have the same meaning as 184 explained in the previous section. These variables can be set on the 185 command line when invoking `make' like this: 186 `make [VARIABLE=VALUE]...' 187 188 WARNINGCXXFLAGS is a non-standard Makefile variable introduced by us 189 to hold several compiler flags related to warnings. Its default value 190 can be overridden when invoking `make'. For example to disable all 191 warning flags use `make WARNINGCXXFLAGS='. 192 193 In order to turn off a single flag from the default set of warning 194 flags, you can use the CXXFLAGS variable, since this is passed after 195 WARNINGCXXFLAGS. For example to turn off `-Wold-style-cast' (which is 196 used by default when g++ is detected) you can use 197 `make CXXFLAGS="-g -O2 -Wno-old-style-cast"'. -
doc/CMakeLists.txt
r744 r827 27 27 COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps 28 28 COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps 29 COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/planar.png ${CMAKE_CURRENT_SOURCE_DIR}/images/planar.eps 29 30 COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps 30 31 COMMAND ${CMAKE_COMMAND} -E remove_directory html -
doc/Makefile.am
r744 r827 29 29 edge_biconnected_components.eps \ 30 30 node_biconnected_components.eps \ 31 planar.eps \ 31 32 strongly_connected_components.eps 32 33 -
doc/groups.dox
r771 r813 407 407 - \ref NetworkSimplex Primal Network Simplex algorithm with various 408 408 pivot strategies \ref dantzig63linearprog, \ref kellyoneill91netsimplex. 409 - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on410 cost scaling\ref goldberg90approximation, \ref goldberg97efficient,409 - \ref CostScaling Cost Scaling algorithm based on push/augment and 410 relabel operations \ref goldberg90approximation, \ref goldberg97efficient, 411 411 \ref bunnagel98efficient. 412 - \ref CapacityScaling Successive Shortest %Path algorithm with optional 413 capacity scaling \ref edmondskarp72theoretical. 414 - \ref CancelAndTighten The Cancel and Tighten algorithm 415 \ref goldberg89cyclecanceling. 416 - \ref CycleCanceling Cycle-Canceling algorithms 417 \ref klein67primal, \ref goldberg89cyclecanceling. 412 - \ref CapacityScaling Capacity Scaling algorithm based on the successive 413 shortest path method \ref edmondskarp72theoretical. 414 - \ref CycleCanceling Cycle-Canceling algorithms, two of which are 415 strongly polynomial \ref klein67primal, \ref goldberg89cyclecanceling. 418 416 419 417 In general NetworkSimplex is the most efficient implementation, -
lemon/Makefile.am
r799 r822 63 63 lemon/binom_heap.h \ 64 64 lemon/bucket_heap.h \ 65 lemon/capacity_scaling.h \ 65 66 lemon/cbc.h \ 66 67 lemon/circulation.h \ … … 69 70 lemon/concept_check.h \ 70 71 lemon/connectivity.h \ 72 lemon/core.h \ 73 lemon/cost_scaling.h \ 71 74 lemon/counter.h \ 72 lemon/core.h \73 75 lemon/cplex.h \ 76 lemon/cycle_canceling.h \ 74 77 lemon/dfs.h \ 75 78 lemon/dijkstra.h \ -
lemon/bellman_ford.h
r788 r825 172 172 /// the lengths of the arcs. The default map type is 173 173 /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". 174 /// \tparam TR The traits class that defines various types used by the 175 /// algorithm. By default, it is \ref BellmanFordDefaultTraits 176 /// "BellmanFordDefaultTraits<GR, LEN>". 177 /// In most cases, this parameter should not be set directly, 178 /// consider to use the named template parameters instead. 174 179 #ifdef DOXYGEN 175 180 template <typename GR, typename LEN, typename TR> … … 238 243 _dist = Traits::createDistMap(*_gr); 239 244 } 240 _mask = new MaskMap(*_gr, false); 245 if(!_mask) { 246 _mask = new MaskMap(*_gr); 247 } 241 248 } 242 249 … … 404 411 _process.push_back(it); 405 412 _mask->set(it, true); 413 } 414 } else { 415 for (NodeIt it(*_gr); it != INVALID; ++it) { 416 _mask->set(it, false); 406 417 } 407 418 } … … 928 939 /// This class should only be used through the \ref bellmanFord() 929 940 /// function, which makes it easier to use the algorithm. 941 /// 942 /// \tparam TR The traits class that defines various types used by the 943 /// algorithm. 930 944 template<class TR> 931 945 class BellmanFordWizard : public TR { -
lemon/bfs.h
r788 r825 122 122 ///\tparam GR The type of the digraph the algorithm runs on. 123 123 ///The default type is \ref ListDigraph. 124 ///\tparam TR The traits class that defines various types used by the 125 ///algorithm. By default, it is \ref BfsDefaultTraits 126 ///"BfsDefaultTraits<GR>". 127 ///In most cases, this parameter should not be set directly, 128 ///consider to use the named template parameters instead. 124 129 #ifdef DOXYGEN 125 130 template <typename GR, … … 958 963 /// This class should only be used through the \ref bfs() function, 959 964 /// which makes it easier to use the algorithm. 965 /// 966 /// \tparam TR The traits class that defines various types used by the 967 /// algorithm. 960 968 template<class TR> 961 969 class BfsWizard : public TR … … 1296 1304 /// does not observe the BFS events. If you want to observe the BFS 1297 1305 /// events, you should implement your own visitor class. 1298 /// \tparam TR T raits class to set various datatypes used by the1299 /// algorithm. The default traits class is1300 /// \ref BfsVisitDefaultTraits"BfsVisitDefaultTraits<GR>".1301 /// See \ref BfsVisitDefaultTraits for the documentation of1302 /// a BFS visit traits class.1306 /// \tparam TR The traits class that defines various types used by the 1307 /// algorithm. By default, it is \ref BfsVisitDefaultTraits 1308 /// "BfsVisitDefaultTraits<GR>". 1309 /// In most cases, this parameter should not be set directly, 1310 /// consider to use the named template parameters instead. 1303 1311 #ifdef DOXYGEN 1304 1312 template <typename GR, typename VS, typename TR> -
lemon/bits/map_extender.h
r718 r802 85 85 typedef typename Map::Value Value; 86 86 87 MapIt() {}88 89 MapIt(Invalid i) : Parent(i) {}90 91 explicit MapIt(Map& _map) : map( _map) {92 map .notifier()->first(*this);87 MapIt() : map(NULL) {} 88 89 MapIt(Invalid i) : Parent(i), map(NULL) {} 90 91 explicit MapIt(Map& _map) : map(&_map) { 92 map->notifier()->first(*this); 93 93 } 94 94 95 95 MapIt(const Map& _map, const Item& item) 96 : Parent(item), map(&_map) {} 97 98 MapIt& operator++() { 99 map->notifier()->next(*this); 100 return *this; 101 } 102 103 typename MapTraits<Map>::ConstReturnValue operator*() const { 104 return (*map)[*this]; 105 } 106 107 typename MapTraits<Map>::ReturnValue operator*() { 108 return (*map)[*this]; 109 } 110 111 void set(const Value& value) { 112 map->set(*this, value); 113 } 114 115 protected: 116 Map* map; 117 118 }; 119 120 class ConstMapIt : public Item { 121 typedef Item Parent; 122 123 public: 124 125 typedef typename Map::Value Value; 126 127 ConstMapIt() : map(NULL) {} 128 129 ConstMapIt(Invalid i) : Parent(i), map(NULL) {} 130 131 explicit ConstMapIt(Map& _map) : map(&_map) { 132 map->notifier()->first(*this); 133 } 134 135 ConstMapIt(const Map& _map, const Item& item) 96 136 : Parent(item), map(_map) {} 97 137 98 MapIt& operator++() {99 map .notifier()->next(*this);138 ConstMapIt& operator++() { 139 map->notifier()->next(*this); 100 140 return *this; 101 141 } … … 105 145 } 106 146 107 typename MapTraits<Map>::ReturnValue operator*() { 108 return map[*this]; 109 } 110 111 void set(const Value& value) { 112 map.set(*this, value); 113 } 114 115 protected: 116 Map& map; 117 118 }; 119 120 class ConstMapIt : public Item { 121 typedef Item Parent; 122 123 public: 124 125 typedef typename Map::Value Value; 126 127 ConstMapIt() {} 128 129 ConstMapIt(Invalid i) : Parent(i) { } 130 131 explicit ConstMapIt(Map& _map) : map(_map) { 132 map.notifier()->first(*this); 133 } 134 135 ConstMapIt(const Map& _map, const Item& item) 136 : Parent(item), map(_map) {} 137 138 ConstMapIt& operator++() { 139 map.notifier()->next(*this); 140 return *this; 141 } 142 143 typename MapTraits<Map>::ConstReturnValue operator*() const { 144 return map[*this]; 145 } 146 147 protected: 148 const Map& map; 147 protected: 148 const Map* map; 149 149 }; 150 150 … … 153 153 154 154 public: 155 156 ItemIt() {} 157 158 ItemIt(Invalid i) : Parent(i) {}159 160 explicit ItemIt(Map& _map) : map( _map) {161 map .notifier()->first(*this);155 ItemIt() : map(NULL) {} 156 157 158 ItemIt(Invalid i) : Parent(i), map(NULL) {} 159 160 explicit ItemIt(Map& _map) : map(&_map) { 161 map->notifier()->first(*this); 162 162 } 163 163 164 164 ItemIt(const Map& _map, const Item& item) 165 : Parent(item), map( _map) {}165 : Parent(item), map(&_map) {} 166 166 167 167 ItemIt& operator++() { 168 map .notifier()->next(*this);169 return *this; 170 } 171 172 protected: 173 const Map ↦168 map->notifier()->next(*this); 169 return *this; 170 } 171 172 protected: 173 const Map* map; 174 174 175 175 }; … … 232 232 typedef typename Map::Value Value; 233 233 234 MapIt() {}235 236 MapIt(Invalid i) : Parent(i) { }237 238 explicit MapIt(Map& _map) : map( _map) {239 map .graph.first(*this);234 MapIt() : map(NULL) {} 235 236 MapIt(Invalid i) : Parent(i), map(NULL) { } 237 238 explicit MapIt(Map& _map) : map(&_map) { 239 map->graph.first(*this); 240 240 } 241 241 242 242 MapIt(const Map& _map, const Item& item) 243 : Parent(item), map( _map) {}243 : Parent(item), map(&_map) {} 244 244 245 245 MapIt& operator++() { 246 map .graph.next(*this);246 map->graph.next(*this); 247 247 return *this; 248 248 } 249 249 250 250 typename MapTraits<Map>::ConstReturnValue operator*() const { 251 return map[*this];251 return (*map)[*this]; 252 252 } 253 253 254 254 typename MapTraits<Map>::ReturnValue operator*() { 255 return map[*this];255 return (*map)[*this]; 256 256 } 257 257 258 258 void set(const Value& value) { 259 map .set(*this, value);260 } 261 262 protected: 263 Map ↦259 map->set(*this, value); 260 } 261 262 protected: 263 Map* map; 264 264 265 265 }; … … 272 272 typedef typename Map::Value Value; 273 273 274 ConstMapIt() {}275 276 ConstMapIt(Invalid i) : Parent(i) { }277 278 explicit ConstMapIt(Map& _map) : map( _map) {279 map .graph.first(*this);274 ConstMapIt() : map(NULL) {} 275 276 ConstMapIt(Invalid i) : Parent(i), map(NULL) { } 277 278 explicit ConstMapIt(Map& _map) : map(&_map) { 279 map->graph.first(*this); 280 280 } 281 281 282 282 ConstMapIt(const Map& _map, const Item& item) 283 : Parent(item), map( _map) {}283 : Parent(item), map(&_map) {} 284 284 285 285 ConstMapIt& operator++() { 286 map .graph.next(*this);286 map->graph.next(*this); 287 287 return *this; 288 288 } 289 289 290 290 typename MapTraits<Map>::ConstReturnValue operator*() const { 291 return map[*this];292 } 293 294 protected: 295 const Map ↦291 return (*map)[*this]; 292 } 293 294 protected: 295 const Map* map; 296 296 }; 297 297 … … 300 300 301 301 public: 302 303 ItemIt() {} 304 305 ItemIt(Invalid i) : Parent(i) { }306 307 explicit ItemIt(Map& _map) : map( _map) {308 map .graph.first(*this);302 ItemIt() : map(NULL) {} 303 304 305 ItemIt(Invalid i) : Parent(i), map(NULL) { } 306 307 explicit ItemIt(Map& _map) : map(&_map) { 308 map->graph.first(*this); 309 309 } 310 310 311 311 ItemIt(const Map& _map, const Item& item) 312 : Parent(item), map( _map) {}312 : Parent(item), map(&_map) {} 313 313 314 314 ItemIt& operator++() { 315 map .graph.next(*this);316 return *this; 317 } 318 319 protected: 320 const Map ↦315 map->graph.next(*this); 316 return *this; 317 } 318 319 protected: 320 const Map* map; 321 321 322 322 }; -
lemon/circulation.h
r786 r825 174 174 \tparam SM The type of the supply map. The default map type is 175 175 \ref concepts::Digraph::NodeMap "GR::NodeMap<UM::Value>". 176 \tparam TR The traits class that defines various types used by the 177 algorithm. By default, it is \ref CirculationDefaultTraits 178 "CirculationDefaultTraits<GR, LM, UM, SM>". 179 In most cases, this parameter should not be set directly, 180 consider to use the named template parameters instead. 176 181 */ 177 182 #ifdef DOXYGEN -
lemon/concepts/heap.h
r710 r817 89 89 /// handle the cross references. The assigned value must be 90 90 /// \c PRE_HEAP (<tt>-1</tt>) for each item. 91 #ifdef DOXYGEN 91 92 explicit Heap(ItemIntMap &map) {} 93 #else 94 explicit Heap(ItemIntMap&) {} 95 #endif 92 96 93 97 /// \brief Constructor. … … 99 103 /// \c PRE_HEAP (<tt>-1</tt>) for each item. 100 104 /// \param comp The function object used for comparing the priorities. 105 #ifdef DOXYGEN 101 106 explicit Heap(ItemIntMap &map, const CMP &comp) {} 107 #else 108 explicit Heap(ItemIntMap&, const CMP&) {} 109 #endif 102 110 103 111 /// \brief The number of items stored in the heap. … … 127 135 /// \param p The priority of the item. 128 136 /// \pre \e i must not be stored in the heap. 137 #ifdef DOXYGEN 129 138 void push(const Item &i, const Prio &p) {} 139 #else 140 void push(const Item&, const Prio&) {} 141 #endif 130 142 131 143 /// \brief Return the item having minimum priority. … … 133 145 /// This function returns the item having minimum priority. 134 146 /// \pre The heap must be non-empty. 135 Item top() const { }147 Item top() const { return Item(); } 136 148 137 149 /// \brief The minimum priority. … … 139 151 /// This function returns the minimum priority. 140 152 /// \pre The heap must be non-empty. 141 Prio prio() const { }153 Prio prio() const { return Prio(); } 142 154 143 155 /// \brief Remove the item having minimum priority. … … 153 165 /// \param i The item to delete. 154 166 /// \pre \e i must be in the heap. 167 #ifdef DOXYGEN 155 168 void erase(const Item &i) {} 169 #else 170 void erase(const Item&) {} 171 #endif 156 172 157 173 /// \brief The priority of the given item. … … 160 176 /// \param i The item. 161 177 /// \pre \e i must be in the heap. 178 #ifdef DOXYGEN 162 179 Prio operator[](const Item &i) const {} 180 #else 181 Prio operator[](const Item&) const { return Prio(); } 182 #endif 163 183 164 184 /// \brief Set the priority of an item or insert it, if it is … … 171 191 /// \param i The item. 172 192 /// \param p The priority. 193 #ifdef DOXYGEN 173 194 void set(const Item &i, const Prio &p) {} 195 #else 196 void set(const Item&, const Prio&) {} 197 #endif 174 198 175 199 /// \brief Decrease the priority of an item to the given value. … … 179 203 /// \param p The priority. 180 204 /// \pre \e i must be stored in the heap with priority at least \e p. 205 #ifdef DOXYGEN 181 206 void decrease(const Item &i, const Prio &p) {} 207 #else 208 void decrease(const Item&, const Prio&) {} 209 #endif 182 210 183 211 /// \brief Increase the priority of an item to the given value. … … 187 215 /// \param p The priority. 188 216 /// \pre \e i must be stored in the heap with priority at most \e p. 217 #ifdef DOXYGEN 189 218 void increase(const Item &i, const Prio &p) {} 219 #else 220 void increase(const Item&, const Prio&) {} 221 #endif 190 222 191 223 /// \brief Return the state of an item. … … 197 229 /// to the heap again. 198 230 /// \param i The item. 231 #ifdef DOXYGEN 199 232 State state(const Item &i) const {} 233 #else 234 State state(const Item&) const { return PRE_HEAP; } 235 #endif 200 236 201 237 /// \brief Set the state of an item in the heap. … … 206 242 /// \param i The item. 207 243 /// \param st The state. It should not be \c IN_HEAP. 244 #ifdef DOXYGEN 208 245 void state(const Item& i, State st) {} 246 #else 247 void state(const Item&, State) {} 248 #endif 209 249 210 250 -
lemon/dfs.h
r788 r825 122 122 ///\tparam GR The type of the digraph the algorithm runs on. 123 123 ///The default type is \ref ListDigraph. 124 ///\tparam TR The traits class that defines various types used by the 125 ///algorithm. By default, it is \ref DfsDefaultTraits 126 ///"DfsDefaultTraits<GR>". 127 ///In most cases, this parameter should not be set directly, 128 ///consider to use the named template parameters instead. 124 129 #ifdef DOXYGEN 125 130 template <typename GR, … … 888 893 /// This class should only be used through the \ref dfs() function, 889 894 /// which makes it easier to use the algorithm. 895 /// 896 /// \tparam TR The traits class that defines various types used by the 897 /// algorithm. 890 898 template<class TR> 891 899 class DfsWizard : public TR … … 1238 1246 /// does not observe the DFS events. If you want to observe the DFS 1239 1247 /// events, you should implement your own visitor class. 1240 /// \tparam TR T raits class to set various datatypes used by the1241 /// algorithm. The default traits class is1242 /// \ref DfsVisitDefaultTraits"DfsVisitDefaultTraits<GR>".1243 /// See \ref DfsVisitDefaultTraits for the documentation of1244 /// a DFS visit traits class.1248 /// \tparam TR The traits class that defines various types used by the 1249 /// algorithm. By default, it is \ref DfsVisitDefaultTraits 1250 /// "DfsVisitDefaultTraits<GR>". 1251 /// In most cases, this parameter should not be set directly, 1252 /// consider to use the named template parameters instead. 1245 1253 #ifdef DOXYGEN 1246 1254 template <typename GR, typename VS, typename TR> -
lemon/dijkstra.h
r788 r825 193 193 ///it is necessary. The default map type is \ref 194 194 ///concepts::Digraph::ArcMap "GR::ArcMap<int>". 195 ///\tparam TR The traits class that defines various types used by the 196 ///algorithm. By default, it is \ref DijkstraDefaultTraits 197 ///"DijkstraDefaultTraits<GR, LEN>". 198 ///In most cases, this parameter should not be set directly, 199 ///consider to use the named template parameters instead. 195 200 #ifdef DOXYGEN 196 201 template <typename GR, typename LEN, typename TR> … … 1093 1098 /// This class should only be used through the \ref dijkstra() function, 1094 1099 /// which makes it easier to use the algorithm. 1100 /// 1101 /// \tparam TR The traits class that defines various types used by the 1102 /// algorithm. 1095 1103 template<class TR> 1096 1104 class DijkstraWizard : public TR -
lemon/glpk.h
r746 r833 26 26 #include <lemon/lp_base.h> 27 27 28 // forward declaration29 #if !defined _GLP_PROB && !defined GLP_PROB30 #define _GLP_PROB31 #define GLP_PROB32 typedef struct { double _opaque_prob; } glp_prob;33 /* LP/MIP problem object */34 #endif35 36 28 namespace lemon { 37 29 30 namespace _solver_bits { 31 class VoidPtr { 32 private: 33 void *_ptr; 34 public: 35 VoidPtr() : _ptr(0) {} 36 37 template <typename T> 38 VoidPtr(T* ptr) : _ptr(reinterpret_cast<void*>(ptr)) {} 39 40 template <typename T> 41 VoidPtr& operator=(T* ptr) { 42 _ptr = reinterpret_cast<void*>(ptr); 43 return *this; 44 } 45 46 template <typename T> 47 operator T*() const { return reinterpret_cast<T*>(_ptr); } 48 }; 49 } 38 50 39 51 /// \brief Base interface for the GLPK LP and MIP solver … … 44 56 protected: 45 57 46 typedef glp_prob LPX; 47 glp_prob* lp; 58 _solver_bits::VoidPtr lp; 48 59 49 60 GlpkBase(); … … 124 135 125 136 ///Pointer to the underlying GLPK data structure. 126 LPX *lpx() {return lp;}137 _solver_bits::VoidPtr lpx() {return lp;} 127 138 ///Const pointer to the underlying GLPK data structure. 128 const LPX *lpx() const {return lp;}139 _solver_bits::VoidPtr lpx() const {return lp;} 129 140 130 141 ///Returns the constraint identifier understood by GLPK. -
lemon/hartmann_orlin.h
r795 r825 107 107 /// \tparam LEN The type of the length map. The default 108 108 /// map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". 109 /// \tparam TR The traits class that defines various types used by the 110 /// algorithm. By default, it is \ref HartmannOrlinDefaultTraits 111 /// "HartmannOrlinDefaultTraits<GR, LEN>". 112 /// In most cases, this parameter should not be set directly, 113 /// consider to use the named template parameters instead. 109 114 #ifdef DOXYGEN 110 115 template <typename GR, typename LEN, typename TR> … … 128 133 /// 129 134 /// The large value type used for internal computations. 130 /// Using the \ref HartmannOrlinDefaultTraits "default traits class", 131 /// it is \c long \c long if the \c Value type is integer, 135 /// By default, it is \c long \c long if the \c Value type is integer, 132 136 /// otherwise it is \c double. 133 137 typedef typename TR::LargeValue LargeValue; -
lemon/howard.h
r771 r825 107 107 /// \tparam LEN The type of the length map. The default 108 108 /// map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". 109 /// \tparam TR The traits class that defines various types used by the 110 /// algorithm. By default, it is \ref HowardDefaultTraits 111 /// "HowardDefaultTraits<GR, LEN>". 112 /// In most cases, this parameter should not be set directly, 113 /// consider to use the named template parameters instead. 109 114 #ifdef DOXYGEN 110 115 template <typename GR, typename LEN, typename TR> … … 128 133 /// 129 134 /// The large value type used for internal computations. 130 /// Using the \ref HowardDefaultTraits "default traits class", 131 /// it is \c long \c long if the \c Value type is integer, 135 /// By default, it is \c long \c long if the \c Value type is integer, 132 136 /// otherwise it is \c double. 133 137 typedef typename TR::LargeValue LargeValue; -
lemon/karp.h
r772 r825 105 105 /// \tparam LEN The type of the length map. The default 106 106 /// map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". 107 /// \tparam TR The traits class that defines various types used by the 108 /// algorithm. By default, it is \ref KarpDefaultTraits 109 /// "KarpDefaultTraits<GR, LEN>". 110 /// In most cases, this parameter should not be set directly, 111 /// consider to use the named template parameters instead. 107 112 #ifdef DOXYGEN 108 113 template <typename GR, typename LEN, typename TR> … … 126 131 /// 127 132 /// The large value type used for internal computations. 128 /// Using the \ref KarpDefaultTraits "default traits class", 129 /// it is \c long \c long if the \c Value type is integer, 133 /// By default, it is \c long \c long if the \c Value type is integer, 130 134 /// otherwise it is \c double. 131 135 typedef typename TR::LargeValue LargeValue; -
lemon/min_cost_arborescence.h
r713 r825 113 113 /// it is necessary. The default map type is \ref 114 114 /// concepts::Digraph::ArcMap "Digraph::ArcMap<int>". 115 /// \param TR Traits class to set various data types used 116 /// by the algorithm. The default traits class is 117 /// \ref MinCostArborescenceDefaultTraits 115 /// \tparam TR The traits class that defines various types used by the 116 /// algorithm. By default, it is \ref MinCostArborescenceDefaultTraits 118 117 /// "MinCostArborescenceDefaultTraits<GR, CM>". 118 /// In most cases, this parameter should not be set directly, 119 /// consider to use the named template parameters instead. 119 120 #ifndef DOXYGEN 120 121 template <typename GR, … … 123 124 MinCostArborescenceDefaultTraits<GR, CM> > 124 125 #else 125 template <typename GR, typename CM, type defTR>126 template <typename GR, typename CM, typename TR> 126 127 #endif 127 128 class MinCostArborescence { -
lemon/network_simplex.h
r788 r830 44 44 /// \ref amo93networkflows, \ref dantzig63linearprog, 45 45 /// \ref kellyoneill91netsimplex. 46 /// This algorithm is a specialized version of the linear programming47 /// simplex method directly for the minimum cost flow problem.48 /// It is one of the most efficient solution methods.46 /// This algorithm is a highly efficient specialized version of the 47 /// linear programming simplex method directly for the minimum cost 48 /// flow problem. 49 49 /// 50 /// In general this classis the fastest implementation available51 /// in LEMON for th e minimum cost flowproblem.52 /// Moreover it supports both directions of the supply/demand inequality50 /// In general, %NetworkSimplex is the fastest implementation available 51 /// in LEMON for this problem. 52 /// Moreover, it supports both directions of the supply/demand inequality 53 53 /// constraints. For more information, see \ref SupplyType. 54 54 /// … … 59 59 /// 60 60 /// \tparam GR The digraph type the algorithm runs on. 61 /// \tparam V The valuetype used for flow amounts, capacity bounds61 /// \tparam V The number type used for flow amounts, capacity bounds 62 62 /// and supply values in the algorithm. By default, it is \c int. 63 /// \tparam C The valuetype used for costs and potentials in the63 /// \tparam C The number type used for costs and potentials in the 64 64 /// algorithm. By default, it is the same as \c V. 65 65 /// 66 /// \warning Both valuetypes must be signed and all input data must66 /// \warning Both number types must be signed and all input data must 67 67 /// be integer. 68 68 /// … … 127 127 /// By default, \ref BLOCK_SEARCH "Block Search" is used, which 128 128 /// proved to be the most efficient and the most robust on various 129 /// test inputs according to our benchmark tests.129 /// test inputs. 130 130 /// However, another pivot rule can be selected using the \ref run() 131 131 /// function with the proper parameter. … … 165 165 166 166 typedef std::vector<int> IntVector; 167 typedef std::vector< bool> BoolVector;167 typedef std::vector<char> CharVector; 168 168 typedef std::vector<Value> ValueVector; 169 169 typedef std::vector<Cost> CostVector; … … 195 195 IntVector _source; 196 196 IntVector _target; 197 bool _arc_mixing; 197 198 198 199 // Node and arc data … … 213 214 IntVector _last_succ; 214 215 IntVector _dirty_revs; 215 BoolVector _forward;216 IntVector _state;216 CharVector _forward; 217 CharVector _state; 217 218 int _root; 218 219 … … 222 223 int stem, par_stem, new_stem; 223 224 Value delta; 225 226 const Value MAX; 224 227 225 228 public: … … 243 246 const IntVector &_target; 244 247 const CostVector &_cost; 245 const IntVector&_state;248 const CharVector &_state; 246 249 const CostVector &_pi; 247 250 int &_in_arc; … … 295 298 const IntVector &_target; 296 299 const CostVector &_cost; 297 const IntVector&_state;300 const CharVector &_state; 298 301 const CostVector &_pi; 299 302 int &_in_arc; … … 334 337 const IntVector &_target; 335 338 const CostVector &_cost; 336 const IntVector&_state;339 const CharVector &_state; 337 340 const CostVector &_pi; 338 341 int &_in_arc; … … 407 410 const IntVector &_target; 408 411 const CostVector &_cost; 409 const IntVector&_state;412 const CharVector &_state; 410 413 const CostVector &_pi; 411 414 int &_in_arc; … … 510 513 const IntVector &_target; 511 514 const CostVector &_cost; 512 const IntVector&_state;515 const CharVector &_state; 513 516 const CostVector &_pi; 514 517 int &_in_arc; … … 632 635 NetworkSimplex(const GR& graph, bool arc_mixing = false) : 633 636 _graph(graph), _node_id(graph), _arc_id(graph), 637 _arc_mixing(arc_mixing), 638 MAX(std::numeric_limits<Value>::max()), 634 639 INF(std::numeric_limits<Value>::has_infinity ? 635 std::numeric_limits<Value>::infinity() : 636 std::numeric_limits<Value>::max()) 640 std::numeric_limits<Value>::infinity() : MAX) 637 641 { 638 // Check the valuetypes642 // Check the number types 639 643 LEMON_ASSERT(std::numeric_limits<Value>::is_signed, 640 644 "The flow type of NetworkSimplex must be signed"); … … 642 646 "The cost type of NetworkSimplex must be signed"); 643 647 644 // Resize vectors 645 _node_num = countNodes(_graph); 646 _arc_num = countArcs(_graph); 647 int all_node_num = _node_num + 1; 648 int max_arc_num = _arc_num + 2 * _node_num; 649 650 _source.resize(max_arc_num); 651 _target.resize(max_arc_num); 652 653 _lower.resize(_arc_num); 654 _upper.resize(_arc_num); 655 _cap.resize(max_arc_num); 656 _cost.resize(max_arc_num); 657 _supply.resize(all_node_num); 658 _flow.resize(max_arc_num); 659 _pi.resize(all_node_num); 660 661 _parent.resize(all_node_num); 662 _pred.resize(all_node_num); 663 _forward.resize(all_node_num); 664 _thread.resize(all_node_num); 665 _rev_thread.resize(all_node_num); 666 _succ_num.resize(all_node_num); 667 _last_succ.resize(all_node_num); 668 _state.resize(max_arc_num); 669 670 // Copy the graph 671 int i = 0; 672 for (NodeIt n(_graph); n != INVALID; ++n, ++i) { 673 _node_id[n] = i; 674 } 675 if (arc_mixing) { 676 // Store the arcs in a mixed order 677 int k = std::max(int(std::sqrt(double(_arc_num))), 10); 678 int i = 0, j = 0; 679 for (ArcIt a(_graph); a != INVALID; ++a) { 680 _arc_id[a] = i; 681 _source[i] = _node_id[_graph.source(a)]; 682 _target[i] = _node_id[_graph.target(a)]; 683 if ((i += k) >= _arc_num) i = ++j; 684 } 685 } else { 686 // Store the arcs in the original order 687 int i = 0; 688 for (ArcIt a(_graph); a != INVALID; ++a, ++i) { 689 _arc_id[a] = i; 690 _source[i] = _node_id[_graph.source(a)]; 691 _target[i] = _node_id[_graph.target(a)]; 692 } 693 } 694 695 // Reset parameters 648 // Reset data structures 696 649 reset(); 697 650 } … … 728 681 /// If it is not used before calling \ref run(), the upper bounds 729 682 /// will be set to \ref INF on all arcs (i.e. the flow value will be 730 /// unbounded from above on each arc).683 /// unbounded from above). 731 684 /// 732 685 /// \param map An arc map storing the upper bounds. … … 841 794 /// \endcode 842 795 /// 843 /// This function can be called more than once. All the parameters844 /// that have been given are kept for the next call, unless845 /// \ref reset() is called, thus only the modified parameters846 /// have to be set again. See \ref reset() for examples.847 /// However, the underlying digraph must not be modified after this848 /// class have been constructed, since it copies and extends the graph.796 /// This function can be called more than once. All the given parameters 797 /// are kept for the next call, unless \ref resetParams() or \ref reset() 798 /// is used, thus only the modified parameters have to be set again. 799 /// If the underlying digraph was also modified after the construction 800 /// of the class (or the last \ref reset() call), then the \ref reset() 801 /// function must be called. 849 802 /// 850 803 /// \param pivot_rule The pivot rule that will be used during the … … 860 813 /// 861 814 /// \see ProblemType, PivotRule 815 /// \see resetParams(), reset() 862 816 ProblemType run(PivotRule pivot_rule = BLOCK_SEARCH) { 863 817 if (!init()) return INFEASIBLE; … … 871 825 /// \ref costMap(), \ref supplyMap(), \ref stSupply(), \ref supplyType(). 872 826 /// 873 /// It is useful for multiple run() calls. If this function is not 874 /// used, all the parameters given before are kept for the next 875 /// \ref run() call. 876 /// However, the underlying digraph must not be modified after this 877 /// class have been constructed, since it copies and extends the graph. 827 /// It is useful for multiple \ref run() calls. Basically, all the given 828 /// parameters are kept for the next \ref run() call, unless 829 /// \ref resetParams() or \ref reset() is used. 830 /// If the underlying digraph was also modified after the construction 831 /// of the class or the last \ref reset() call, then the \ref reset() 832 /// function must be used, otherwise \ref resetParams() is sufficient. 878 833 /// 879 834 /// For example, … … 885 840 /// .supplyMap(sup).run(); 886 841 /// 887 /// // Run again with modified cost map (reset () is not called,842 /// // Run again with modified cost map (resetParams() is not called, 888 843 /// // so only the cost map have to be set again) 889 844 /// cost[e] += 100; 890 845 /// ns.costMap(cost).run(); 891 846 /// 892 /// // Run again from scratch using reset ()847 /// // Run again from scratch using resetParams() 893 848 /// // (the lower bounds will be set to zero on all arcs) 894 /// ns.reset ();849 /// ns.resetParams(); 895 850 /// ns.upperMap(capacity).costMap(cost) 896 851 /// .supplyMap(sup).run(); … … 898 853 /// 899 854 /// \return <tt>(*this)</tt> 900 NetworkSimplex& reset() { 855 /// 856 /// \see reset(), run() 857 NetworkSimplex& resetParams() { 901 858 for (int i = 0; i != _node_num; ++i) { 902 859 _supply[i] = 0; … … 912 869 } 913 870 871 /// \brief Reset the internal data structures and all the parameters 872 /// that have been given before. 873 /// 874 /// This function resets the internal data structures and all the 875 /// paramaters that have been given before using functions \ref lowerMap(), 876 /// \ref upperMap(), \ref costMap(), \ref supplyMap(), \ref stSupply(), 877 /// \ref supplyType(). 878 /// 879 /// It is useful for multiple \ref run() calls. Basically, all the given 880 /// parameters are kept for the next \ref run() call, unless 881 /// \ref resetParams() or \ref reset() is used. 882 /// If the underlying digraph was also modified after the construction 883 /// of the class or the last \ref reset() call, then the \ref reset() 884 /// function must be used, otherwise \ref resetParams() is sufficient. 885 /// 886 /// See \ref resetParams() for examples. 887 /// 888 /// \return <tt>(*this)</tt> 889 /// 890 /// \see resetParams(), run() 891 NetworkSimplex& reset() { 892 // Resize vectors 893 _node_num = countNodes(_graph); 894 _arc_num = countArcs(_graph); 895 int all_node_num = _node_num + 1; 896 int max_arc_num = _arc_num + 2 * _node_num; 897 898 _source.resize(max_arc_num); 899 _target.resize(max_arc_num); 900 901 _lower.resize(_arc_num); 902 _upper.resize(_arc_num); 903 _cap.resize(max_arc_num); 904 _cost.resize(max_arc_num); 905 _supply.resize(all_node_num); 906 _flow.resize(max_arc_num); 907 _pi.resize(all_node_num); 908 909 _parent.resize(all_node_num); 910 _pred.resize(all_node_num); 911 _forward.resize(all_node_num); 912 _thread.resize(all_node_num); 913 _rev_thread.resize(all_node_num); 914 _succ_num.resize(all_node_num); 915 _last_succ.resize(all_node_num); 916 _state.resize(max_arc_num); 917 918 // Copy the graph 919 int i = 0; 920 for (NodeIt n(_graph); n != INVALID; ++n, ++i) { 921 _node_id[n] = i; 922 } 923 if (_arc_mixing) { 924 // Store the arcs in a mixed order 925 int k = std::max(int(std::sqrt(double(_arc_num))), 10); 926 int i = 0, j = 0; 927 for (ArcIt a(_graph); a != INVALID; ++a) { 928 _arc_id[a] = i; 929 _source[i] = _node_id[_graph.source(a)]; 930 _target[i] = _node_id[_graph.target(a)]; 931 if ((i += k) >= _arc_num) i = ++j; 932 } 933 } else { 934 // Store the arcs in the original order 935 int i = 0; 936 for (ArcIt a(_graph); a != INVALID; ++a, ++i) { 937 _arc_id[a] = i; 938 _source[i] = _node_id[_graph.source(a)]; 939 _target[i] = _node_id[_graph.target(a)]; 940 } 941 } 942 943 // Reset parameters 944 resetParams(); 945 return *this; 946 } 947 914 948 /// @} 915 949 … … 1021 1055 Value c = _lower[i]; 1022 1056 if (c >= 0) { 1023 _cap[i] = _upper[i] < INF? _upper[i] - c : INF;1057 _cap[i] = _upper[i] < MAX ? _upper[i] - c : INF; 1024 1058 } else { 1025 _cap[i] = _upper[i] < INF+ c ? _upper[i] - c : INF;1059 _cap[i] = _upper[i] < MAX + c ? _upper[i] - c : INF; 1026 1060 } 1027 1061 _supply[_source[i]] -= c; … … 1215 1249 e = _pred[u]; 1216 1250 d = _forward[u] ? 1217 _flow[e] : (_cap[e] == INF? INF : _cap[e] - _flow[e]);1251 _flow[e] : (_cap[e] >= MAX ? INF : _cap[e] - _flow[e]); 1218 1252 if (d < delta) { 1219 1253 delta = d; … … 1226 1260 e = _pred[u]; 1227 1261 d = _forward[u] ? 1228 (_cap[e] == INF? INF : _cap[e] - _flow[e]) : _flow[e];1262 (_cap[e] >= MAX ? INF : _cap[e] - _flow[e]) : _flow[e]; 1229 1263 if (d <= delta) { 1230 1264 delta = d; … … 1425 1459 findJoinNode(); 1426 1460 bool change = findLeavingArc(); 1427 if (delta >= INF) return UNBOUNDED;1461 if (delta >= MAX) return UNBOUNDED; 1428 1462 changeFlow(change); 1429 1463 if (change) { -
lemon/planarity.h
r798 r828 519 519 /// 520 520 /// This function implements the Boyer-Myrvold algorithm for 521 /// planarity checking of an undirected graph. It is a simplified521 /// planarity checking of an undirected simple graph. It is a simplified 522 522 /// version of the PlanarEmbedding algorithm class because neither 523 /// the embedding nor the kuratowski subdivisons are notcomputed.523 /// the embedding nor the Kuratowski subdivisons are computed. 524 524 template <typename GR> 525 525 bool checkPlanarity(const GR& graph) { … … 533 533 /// 534 534 /// This class implements the Boyer-Myrvold algorithm for planar 535 /// embedding of an undirected graph. The planar embedding is an535 /// embedding of an undirected simple graph. The planar embedding is an 536 536 /// ordering of the outgoing edges of the nodes, which is a possible 537 537 /// configuration to draw the graph in the plane. If there is not 538 /// such ordering then the graph contains a \f$ K_5 \f$(full graph539 /// with 5 nodes) or a \f$ K_{3,3} \f$(complete bipartite graph on540 /// 3 ANode and 3 BNode) subdivision.538 /// such ordering then the graph contains a K<sub>5</sub> (full graph 539 /// with 5 nodes) or a K<sub>3,3</sub> (complete bipartite graph on 540 /// 3 Red and 3 Blue nodes) subdivision. 541 541 /// 542 542 /// The current implementation calculates either an embedding or a 543 /// Kuratowski subdivision. The running time of the algorithm is 544 /// \f$ O(n) \f$. 543 /// Kuratowski subdivision. The running time of the algorithm is O(n). 544 /// 545 /// \see PlanarDrawing, checkPlanarity() 545 546 template <typename Graph> 546 547 class PlanarEmbedding { … … 592 593 public: 593 594 594 /// \brief The map for store of embedding 595 /// \brief The map type for storing the embedding 596 /// 597 /// The map type for storing the embedding. 598 /// \see embeddingMap() 595 599 typedef typename Graph::template ArcMap<Arc> EmbeddingMap; 596 600 597 601 /// \brief Constructor 598 602 /// 599 /// \note The graph should be simple, i.e. parallel and loop arc 600 /// free. 603 /// Constructor. 604 /// \pre The graph must be simple, i.e. it should not 605 /// contain parallel or loop arcs. 601 606 PlanarEmbedding(const Graph& graph) 602 607 : _graph(graph), _embedding(_graph), _kuratowski(graph, false) {} 603 608 604 /// \brief Run sthe algorithm.609 /// \brief Run the algorithm. 605 610 /// 606 /// Runs the algorithm.607 /// \param kuratowski If th e parameter isfalse, then the611 /// This function runs the algorithm. 612 /// \param kuratowski If this parameter is set to \c false, then the 608 613 /// algorithm does not compute a Kuratowski subdivision. 609 /// \return %True whenthe graph is planar.614 /// \return \c true if the graph is planar. 610 615 bool run(bool kuratowski = true) { 611 616 typedef _planarity_bits::PlanarityVisitor<Graph> Visitor; … … 700 705 } 701 706 702 /// \brief Give sback the successor of an arc707 /// \brief Give back the successor of an arc 703 708 /// 704 /// Gives back the successor of an arc. This functionmakes709 /// This function gives back the successor of an arc. It makes 705 710 /// possible to query the cyclic order of the outgoing arcs from 706 711 /// a node. … … 709 714 } 710 715 711 /// \brief Give sback the calculated embedding map716 /// \brief Give back the calculated embedding map 712 717 /// 713 /// The returned map contains the successor of each arc in the 714 /// graph. 718 /// This function gives back the calculated embedding map, which 719 /// contains the successor of each arc in the cyclic order of the 720 /// outgoing arcs of its source node. 715 721 const EmbeddingMap& embeddingMap() const { 716 722 return _embedding; 717 723 } 718 724 719 /// \brief Give s back true if the undirected arc is in the720 /// kuratowskisubdivision725 /// \brief Give back \c true if the given edge is in the Kuratowski 726 /// subdivision 721 727 /// 722 /// Gives back true if the undirected arc is in the kuratowski 723 /// subdivision 724 /// \note The \c run() had to be called with true value. 725 bool kuratowski(const Edge& edge) { 728 /// This function gives back \c true if the given edge is in the found 729 /// Kuratowski subdivision. 730 /// \pre The \c run() function must be called with \c true parameter 731 /// before using this function. 732 bool kuratowski(const Edge& edge) const { 726 733 return _kuratowski[edge]; 727 734 } … … 2060 2067 /// 2061 2068 /// The planar drawing algorithm calculates positions for the nodes 2062 /// in the plane which coordinates satisfy that if the arcs are2063 /// represented with straight lines then they will not intersect2069 /// in the plane. These coordinates satisfy that if the edges are 2070 /// represented with straight lines, then they will not intersect 2064 2071 /// each other. 2065 2072 /// 2066 /// Scnyder's algorithm embeds the graph on \c (n-2,n-2) size grid,2067 /// i.e. each node will be located in the \c [0 ,n-2]x[0,n-2] square.2073 /// Scnyder's algorithm embeds the graph on an \c (n-2)x(n-2) size grid, 2074 /// i.e. each node will be located in the \c [0..n-2]x[0..n-2] square. 2068 2075 /// The time complexity of the algorithm is O(n). 2076 /// 2077 /// \see PlanarEmbedding 2069 2078 template <typename Graph> 2070 2079 class PlanarDrawing { … … 2073 2082 TEMPLATE_GRAPH_TYPEDEFS(Graph); 2074 2083 2075 /// \brief The point type for stor ecoordinates2084 /// \brief The point type for storing coordinates 2076 2085 typedef dim2::Point<int> Point; 2077 /// \brief The map type for stor e coordinates2086 /// \brief The map type for storing the coordinates of the nodes 2078 2087 typedef typename Graph::template NodeMap<Point> PointMap; 2079 2088 … … 2082 2091 /// 2083 2092 /// Constructor 2084 /// \pre The graph should be simple, i.e. loop and parallel arc free. 2093 /// \pre The graph must be simple, i.e. it should not 2094 /// contain parallel or loop arcs. 2085 2095 PlanarDrawing(const Graph& graph) 2086 2096 : _graph(graph), _point_map(graph) {} … … 2367 2377 public: 2368 2378 2369 /// \brief Calculate sthe node positions2379 /// \brief Calculate the node positions 2370 2380 /// 2371 /// This function calculates the node positions .2372 /// \return %True if the graph is planar.2381 /// This function calculates the node positions on the plane. 2382 /// \return \c true if the graph is planar. 2373 2383 bool run() { 2374 2384 PlanarEmbedding<Graph> pe(_graph); … … 2379 2389 } 2380 2390 2381 /// \brief Calculate sthe node positions according to a2391 /// \brief Calculate the node positions according to a 2382 2392 /// combinatorical embedding 2383 2393 /// 2384 /// This function calculates the node locations. The \c embedding 2385 /// parameter should contain a valid combinatorical embedding, i.e. 2386 /// a valid cyclic order of the arcs. 2394 /// This function calculates the node positions on the plane. 2395 /// The given \c embedding map should contain a valid combinatorical 2396 /// embedding, i.e. a valid cyclic order of the arcs. 2397 /// It can be computed using PlanarEmbedding. 2387 2398 template <typename EmbeddingMap> 2388 2399 void run(const EmbeddingMap& embedding) { … … 2424 2435 /// \brief The coordinate of the given node 2425 2436 /// 2426 /// Th e coordinate of the given node.2437 /// This function returns the coordinate of the given node. 2427 2438 Point operator[](const Node& node) const { 2428 2439 return _point_map[node]; 2429 2440 } 2430 2441 2431 /// \brief Return s the grid embedding in a \e NodeMap.2442 /// \brief Return the grid embedding in a node map 2432 2443 /// 2433 /// Returns the grid embedding in a \e NodeMap of \c dim2::Point<int> . 2444 /// This function returns the grid embedding in a node map of 2445 /// \c dim2::Point<int> coordinates. 2434 2446 const PointMap& coords() const { 2435 2447 return _point_map; … … 2471 2483 /// 2472 2484 /// The graph coloring problem is the coloring of the graph nodes 2473 /// that there are notadjacent nodes with the same color. The2474 /// planar graphs can be always colored with four colors, itis2475 /// proved by Appel and Haken and their proofs provide a quadratic2485 /// so that there are no adjacent nodes with the same color. The 2486 /// planar graphs can always be colored with four colors, which is 2487 /// proved by Appel and Haken. Their proofs provide a quadratic 2476 2488 /// time algorithm for four coloring, but it could not be used to 2477 /// implement efficient algorithm. The five and six coloring can be2478 /// made in linear time, but in this class the five coloring has2489 /// implement an efficient algorithm. The five and six coloring can be 2490 /// made in linear time, but in this class, the five coloring has 2479 2491 /// quadratic worst case time complexity. The two coloring (if 2480 2492 /// possible) is solvable with a graph search algorithm and it is 2481 2493 /// implemented in \ref bipartitePartitions() function in LEMON. To 2482 /// decide whether the planar graph is three colorable is 2483 /// NP-complete. 2494 /// decide whether a planar graph is three colorable is NP-complete. 2484 2495 /// 2485 2496 /// This class contains member functions for calculate colorings 2486 2497 /// with five and six colors. The six coloring algorithm is a simple 2487 2498 /// greedy coloring on the backward minimum outgoing order of nodes. 2488 /// This order can be computed as in each phasethe node with least2489 /// outgoing arcs to unprocessed nodes i s chosen. This order2499 /// This order can be computed by selecting the node with least 2500 /// outgoing arcs to unprocessed nodes in each phase. This order 2490 2501 /// guarantees that when a node is chosen for coloring it has at 2491 2502 /// most five already colored adjacents. The five coloring algorithm … … 2500 2511 TEMPLATE_GRAPH_TYPEDEFS(Graph); 2501 2512 2502 /// \brief The map type for stor e color indexes2513 /// \brief The map type for storing color indices 2503 2514 typedef typename Graph::template NodeMap<int> IndexMap; 2504 /// \brief The map type for store colors 2515 /// \brief The map type for storing colors 2516 /// 2517 /// The map type for storing colors. 2518 /// \see Palette, Color 2505 2519 typedef ComposeMap<Palette, IndexMap> ColorMap; 2506 2520 2507 2521 /// \brief Constructor 2508 2522 /// 2509 /// Constructor 2510 /// \pre The graph should be simple, i.e. loop and parallel arc free. 2523 /// Constructor. 2524 /// \pre The graph must be simple, i.e. it should not 2525 /// contain parallel or loop arcs. 2511 2526 PlanarColoring(const Graph& graph) 2512 2527 : _graph(graph), _color_map(graph), _palette(0) { … … 2519 2534 } 2520 2535 2521 /// \brief Return s the \e NodeMap of color indexes2536 /// \brief Return the node map of color indices 2522 2537 /// 2523 /// Returns the \e NodeMap of color indexes. The values are in the2524 /// range \c [0..4] or \c [0..5] according to the coloring method.2538 /// This function returns the node map of color indices. The values are 2539 /// in the range \c [0..4] or \c [0..5] according to the coloring method. 2525 2540 IndexMap colorIndexMap() const { 2526 2541 return _color_map; 2527 2542 } 2528 2543 2529 /// \brief Return s the \e NodeMap of colors2544 /// \brief Return the node map of colors 2530 2545 /// 2531 /// Returns the \e NodeMap of colors. The values are five or six2532 /// distinct \ref lemon::Color "colors".2546 /// This function returns the node map of colors. The values are among 2547 /// five or six distinct \ref lemon::Color "colors". 2533 2548 ColorMap colorMap() const { 2534 2549 return composeMap(_palette, _color_map); 2535 2550 } 2536 2551 2537 /// \brief Return sthe color index of the node2552 /// \brief Return the color index of the node 2538 2553 /// 2539 /// Returns the color index of the node. The values are in the2540 /// range \c [0..4] or \c [0..5] according to the coloring method.2554 /// This function returns the color index of the given node. The value is 2555 /// in the range \c [0..4] or \c [0..5] according to the coloring method. 2541 2556 int colorIndex(const Node& node) const { 2542 2557 return _color_map[node]; 2543 2558 } 2544 2559 2545 /// \brief Return sthe color of the node2560 /// \brief Return the color of the node 2546 2561 /// 2547 /// Returns the color of the node. The values are five or six2548 /// distinct \ref lemon::Color "colors".2562 /// This function returns the color of the given node. The value is among 2563 /// five or six distinct \ref lemon::Color "colors". 2549 2564 Color color(const Node& node) const { 2550 2565 return _palette[_color_map[node]]; … … 2552 2567 2553 2568 2554 /// \brief Calculate sa coloring with at most six colors2569 /// \brief Calculate a coloring with at most six colors 2555 2570 /// 2556 2571 /// This function calculates a coloring with at most six colors. The time 2557 2572 /// complexity of this variant is linear in the size of the graph. 2558 /// \return %True when the algorithm could color the graph with six color.2559 /// If the algorithm fails, then the graph could not beplanar.2560 /// \note This function can return true if the graph is not2561 /// planar but it can be colored with 6colors.2573 /// \return \c true if the algorithm could color the graph with six colors. 2574 /// If the algorithm fails, then the graph is not planar. 2575 /// \note This function can return \c true if the graph is not 2576 /// planar, but it can be colored with at most six colors. 2562 2577 bool runSixColoring() { 2563 2578 … … 2661 2676 public: 2662 2677 2663 /// \brief Calculate sa coloring with at most five colors2678 /// \brief Calculate a coloring with at most five colors 2664 2679 /// 2665 2680 /// This function calculates a coloring with at most five 2666 2681 /// colors. The worst case time complexity of this variant is 2667 2682 /// quadratic in the size of the graph. 2683 /// \param embedding This map should contain a valid combinatorical 2684 /// embedding, i.e. a valid cyclic order of the arcs. 2685 /// It can be computed using PlanarEmbedding. 2668 2686 template <typename EmbeddingMap> 2669 2687 void runFiveColoring(const EmbeddingMap& embedding) { … … 2712 2730 } 2713 2731 2714 /// \brief Calculate sa coloring with at most five colors2732 /// \brief Calculate a coloring with at most five colors 2715 2733 /// 2716 2734 /// This function calculates a coloring with at most five 2717 2735 /// colors. The worst case time complexity of this variant is 2718 2736 /// quadratic in the size of the graph. 2719 /// \return %True whenthe graph is planar.2737 /// \return \c true if the graph is planar. 2720 2738 bool runFiveColoring() { 2721 2739 PlanarEmbedding<Graph> pe(_graph); -
lemon/preflow.h
r788 r825 114 114 /// second phase constructs a feasible maximum flow on each arc. 115 115 /// 116 /// \warning This implementation cannot handle infinite or very large 117 /// capacities (e.g. the maximum value of \c CAP::Value). 118 /// 116 119 /// \tparam GR The type of the digraph the algorithm runs on. 117 120 /// \tparam CAP The type of the capacity map. The default map 118 121 /// type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". 122 /// \tparam TR The traits class that defines various types used by the 123 /// algorithm. By default, it is \ref PreflowDefaultTraits 124 /// "PreflowDefaultTraits<GR, CAP>". 125 /// In most cases, this parameter should not be set directly, 126 /// consider to use the named template parameters instead. 119 127 #ifdef DOXYGEN 120 128 template <typename GR, typename CAP, typename TR> -
lemon/unionfind.h
r786 r800 740 740 void clear() { 741 741 items.clear(); 742 classes.clear ;742 classes.clear(); 743 743 firstClass = firstFreeClass = firstFreeItem = -1; 744 744 } -
test/min_cost_flow_test.cc
r669 r830 25 25 26 26 #include <lemon/network_simplex.h> 27 #include <lemon/capacity_scaling.h> 28 #include <lemon/cost_scaling.h> 29 #include <lemon/cycle_canceling.h> 27 30 28 31 #include <lemon/concepts/digraph.h> 32 #include <lemon/concepts/heap.h> 29 33 #include <lemon/concept_check.h> 30 34 … … 33 37 using namespace lemon; 34 38 39 // Test networks 35 40 char test_lgf[] = 36 41 "@nodes\n" … … 77 82 "target 12\n"; 78 83 84 char test_neg1_lgf[] = 85 "@nodes\n" 86 "label sup\n" 87 " 1 100\n" 88 " 2 0\n" 89 " 3 0\n" 90 " 4 -100\n" 91 " 5 0\n" 92 " 6 0\n" 93 " 7 0\n" 94 "@arcs\n" 95 " cost low1 low2\n" 96 "1 2 100 0 0\n" 97 "1 3 30 0 0\n" 98 "2 4 20 0 0\n" 99 "3 4 80 0 0\n" 100 "3 2 50 0 0\n" 101 "5 3 10 0 0\n" 102 "5 6 80 0 1000\n" 103 "6 7 30 0 -1000\n" 104 "7 5 -120 0 0\n"; 105 106 char test_neg2_lgf[] = 107 "@nodes\n" 108 "label sup\n" 109 " 1 100\n" 110 " 2 -300\n" 111 "@arcs\n" 112 " cost\n" 113 "1 2 -1\n"; 114 115 116 // Test data 117 typedef ListDigraph Digraph; 118 DIGRAPH_TYPEDEFS(ListDigraph); 119 120 Digraph gr; 121 Digraph::ArcMap<int> c(gr), l1(gr), l2(gr), l3(gr), u(gr); 122 Digraph::NodeMap<int> s1(gr), s2(gr), s3(gr), s4(gr), s5(gr), s6(gr); 123 ConstMap<Arc, int> cc(1), cu(std::numeric_limits<int>::max()); 124 Node v, w; 125 126 Digraph neg1_gr; 127 Digraph::ArcMap<int> neg1_c(neg1_gr), neg1_l1(neg1_gr), neg1_l2(neg1_gr); 128 ConstMap<Arc, int> neg1_u1(std::numeric_limits<int>::max()), neg1_u2(5000); 129 Digraph::NodeMap<int> neg1_s(neg1_gr); 130 131 Digraph neg2_gr; 132 Digraph::ArcMap<int> neg2_c(neg2_gr); 133 ConstMap<Arc, int> neg2_l(0), neg2_u(1000); 134 Digraph::NodeMap<int> neg2_s(neg2_gr); 135 79 136 80 137 enum SupplyType { … … 83 140 LEQ 84 141 }; 142 85 143 86 144 // Check the interface of an MCF algorithm … … 100 158 const MCF& const_mcf = mcf; 101 159 102 b = mcf.reset() 160 b = mcf.reset().resetParams() 103 161 .lowerMap(me.lower) 104 162 .upperMap(me.upper) … … 269 327 } 270 328 329 template < typename MCF, typename Param > 330 void runMcfGeqTests( Param param, 331 const std::string &test_str = "", 332 bool full_neg_cost_support = false ) 333 { 334 MCF mcf1(gr), mcf2(neg1_gr), mcf3(neg2_gr); 335 336 // Basic tests 337 mcf1.upperMap(u).costMap(c).supplyMap(s1); 338 checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s1, 339 mcf1.OPTIMAL, true, 5240, test_str + "-1"); 340 mcf1.stSupply(v, w, 27); 341 checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s2, 342 mcf1.OPTIMAL, true, 7620, test_str + "-2"); 343 mcf1.lowerMap(l2).supplyMap(s1); 344 checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s1, 345 mcf1.OPTIMAL, true, 5970, test_str + "-3"); 346 mcf1.stSupply(v, w, 27); 347 checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s2, 348 mcf1.OPTIMAL, true, 8010, test_str + "-4"); 349 mcf1.resetParams().supplyMap(s1); 350 checkMcf(mcf1, mcf1.run(param), gr, l1, cu, cc, s1, 351 mcf1.OPTIMAL, true, 74, test_str + "-5"); 352 mcf1.lowerMap(l2).stSupply(v, w, 27); 353 checkMcf(mcf1, mcf1.run(param), gr, l2, cu, cc, s2, 354 mcf1.OPTIMAL, true, 94, test_str + "-6"); 355 mcf1.reset(); 356 checkMcf(mcf1, mcf1.run(param), gr, l1, cu, cc, s3, 357 mcf1.OPTIMAL, true, 0, test_str + "-7"); 358 mcf1.lowerMap(l2).upperMap(u); 359 checkMcf(mcf1, mcf1.run(param), gr, l2, u, cc, s3, 360 mcf1.INFEASIBLE, false, 0, test_str + "-8"); 361 mcf1.lowerMap(l3).upperMap(u).costMap(c).supplyMap(s4); 362 checkMcf(mcf1, mcf1.run(param), gr, l3, u, c, s4, 363 mcf1.OPTIMAL, true, 6360, test_str + "-9"); 364 365 // Tests for the GEQ form 366 mcf1.resetParams().upperMap(u).costMap(c).supplyMap(s5); 367 checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s5, 368 mcf1.OPTIMAL, true, 3530, test_str + "-10", GEQ); 369 mcf1.lowerMap(l2); 370 checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s5, 371 mcf1.OPTIMAL, true, 4540, test_str + "-11", GEQ); 372 mcf1.supplyMap(s6); 373 checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s6, 374 mcf1.INFEASIBLE, false, 0, test_str + "-12", GEQ); 375 376 // Tests with negative costs 377 mcf2.lowerMap(neg1_l1).costMap(neg1_c).supplyMap(neg1_s); 378 checkMcf(mcf2, mcf2.run(param), neg1_gr, neg1_l1, neg1_u1, neg1_c, neg1_s, 379 mcf2.UNBOUNDED, false, 0, test_str + "-13"); 380 mcf2.upperMap(neg1_u2); 381 checkMcf(mcf2, mcf2.run(param), neg1_gr, neg1_l1, neg1_u2, neg1_c, neg1_s, 382 mcf2.OPTIMAL, true, -40000, test_str + "-14"); 383 mcf2.resetParams().lowerMap(neg1_l2).costMap(neg1_c).supplyMap(neg1_s); 384 checkMcf(mcf2, mcf2.run(param), neg1_gr, neg1_l2, neg1_u1, neg1_c, neg1_s, 385 mcf2.UNBOUNDED, false, 0, test_str + "-15"); 386 387 mcf3.costMap(neg2_c).supplyMap(neg2_s); 388 if (full_neg_cost_support) { 389 checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s, 390 mcf3.OPTIMAL, true, -300, test_str + "-16", GEQ); 391 } else { 392 checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s, 393 mcf3.UNBOUNDED, false, 0, test_str + "-17", GEQ); 394 } 395 mcf3.upperMap(neg2_u); 396 checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s, 397 mcf3.OPTIMAL, true, -300, test_str + "-18", GEQ); 398 } 399 400 template < typename MCF, typename Param > 401 void runMcfLeqTests( Param param, 402 const std::string &test_str = "" ) 403 { 404 // Tests for the LEQ form 405 MCF mcf1(gr); 406 mcf1.supplyType(mcf1.LEQ); 407 mcf1.upperMap(u).costMap(c).supplyMap(s6); 408 checkMcf(mcf1, mcf1.run(param), gr, l1, u, c, s6, 409 mcf1.OPTIMAL, true, 5080, test_str + "-19", LEQ); 410 mcf1.lowerMap(l2); 411 checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s6, 412 mcf1.OPTIMAL, true, 5930, test_str + "-20", LEQ); 413 mcf1.supplyMap(s5); 414 checkMcf(mcf1, mcf1.run(param), gr, l2, u, c, s5, 415 mcf1.INFEASIBLE, false, 0, test_str + "-21", LEQ); 416 } 417 418 271 419 int main() 272 420 { 273 // Check the interfaces 274 { 275 typedef concepts::Digraph GR; 276 checkConcept< McfClassConcept<GR, int, int>, 277 NetworkSimplex<GR> >(); 278 checkConcept< McfClassConcept<GR, double, double>, 279 NetworkSimplex<GR, double> >(); 280 checkConcept< McfClassConcept<GR, int, double>, 281 NetworkSimplex<GR, int, double> >(); 282 } 283 284 // Run various MCF tests 285 typedef ListDigraph Digraph; 286 DIGRAPH_TYPEDEFS(ListDigraph); 287 288 // Read the test digraph 289 Digraph gr; 290 Digraph::ArcMap<int> c(gr), l1(gr), l2(gr), l3(gr), u(gr); 291 Digraph::NodeMap<int> s1(gr), s2(gr), s3(gr), s4(gr), s5(gr), s6(gr); 292 ConstMap<Arc, int> cc(1), cu(std::numeric_limits<int>::max()); 293 Node v, w; 294 421 // Read the test networks 295 422 std::istringstream input(test_lgf); 296 423 DigraphReader<Digraph>(gr, input) … … 310 437 .run(); 311 438 312 // Build test digraphs with negative costs 313 Digraph neg_gr; 314 Node n1 = neg_gr.addNode(); 315 Node n2 = neg_gr.addNode(); 316 Node n3 = neg_gr.addNode(); 317 Node n4 = neg_gr.addNode(); 318 Node n5 = neg_gr.addNode(); 319 Node n6 = neg_gr.addNode(); 320 Node n7 = neg_gr.addNode(); 321 322 Arc a1 = neg_gr.addArc(n1, n2); 323 Arc a2 = neg_gr.addArc(n1, n3); 324 Arc a3 = neg_gr.addArc(n2, n4); 325 Arc a4 = neg_gr.addArc(n3, n4); 326 Arc a5 = neg_gr.addArc(n3, n2); 327 Arc a6 = neg_gr.addArc(n5, n3); 328 Arc a7 = neg_gr.addArc(n5, n6); 329 Arc a8 = neg_gr.addArc(n6, n7); 330 Arc a9 = neg_gr.addArc(n7, n5); 331 332 Digraph::ArcMap<int> neg_c(neg_gr), neg_l1(neg_gr, 0), neg_l2(neg_gr, 0); 333 ConstMap<Arc, int> neg_u1(std::numeric_limits<int>::max()), neg_u2(5000); 334 Digraph::NodeMap<int> neg_s(neg_gr, 0); 335 336 neg_l2[a7] = 1000; 337 neg_l2[a8] = -1000; 338 339 neg_s[n1] = 100; 340 neg_s[n4] = -100; 341 342 neg_c[a1] = 100; 343 neg_c[a2] = 30; 344 neg_c[a3] = 20; 345 neg_c[a4] = 80; 346 neg_c[a5] = 50; 347 neg_c[a6] = 10; 348 neg_c[a7] = 80; 349 neg_c[a8] = 30; 350 neg_c[a9] = -120; 351 352 Digraph negs_gr; 353 Digraph::NodeMap<int> negs_s(negs_gr); 354 Digraph::ArcMap<int> negs_c(negs_gr); 355 ConstMap<Arc, int> negs_l(0), negs_u(1000); 356 n1 = negs_gr.addNode(); 357 n2 = negs_gr.addNode(); 358 negs_s[n1] = 100; 359 negs_s[n2] = -300; 360 negs_c[negs_gr.addArc(n1, n2)] = -1; 361 362 363 // A. Test NetworkSimplex with the default pivot rule 364 { 365 NetworkSimplex<Digraph> mcf(gr); 366 367 // Check the equality form 368 mcf.upperMap(u).costMap(c); 369 checkMcf(mcf, mcf.supplyMap(s1).run(), 370 gr, l1, u, c, s1, mcf.OPTIMAL, true, 5240, "#A1"); 371 checkMcf(mcf, mcf.stSupply(v, w, 27).run(), 372 gr, l1, u, c, s2, mcf.OPTIMAL, true, 7620, "#A2"); 373 mcf.lowerMap(l2); 374 checkMcf(mcf, mcf.supplyMap(s1).run(), 375 gr, l2, u, c, s1, mcf.OPTIMAL, true, 5970, "#A3"); 376 checkMcf(mcf, mcf.stSupply(v, w, 27).run(), 377 gr, l2, u, c, s2, mcf.OPTIMAL, true, 8010, "#A4"); 378 mcf.reset(); 379 checkMcf(mcf, mcf.supplyMap(s1).run(), 380 gr, l1, cu, cc, s1, mcf.OPTIMAL, true, 74, "#A5"); 381 checkMcf(mcf, mcf.lowerMap(l2).stSupply(v, w, 27).run(), 382 gr, l2, cu, cc, s2, mcf.OPTIMAL, true, 94, "#A6"); 383 mcf.reset(); 384 checkMcf(mcf, mcf.run(), 385 gr, l1, cu, cc, s3, mcf.OPTIMAL, true, 0, "#A7"); 386 checkMcf(mcf, mcf.lowerMap(l2).upperMap(u).run(), 387 gr, l2, u, cc, s3, mcf.INFEASIBLE, false, 0, "#A8"); 388 mcf.reset().lowerMap(l3).upperMap(u).costMap(c).supplyMap(s4); 389 checkMcf(mcf, mcf.run(), 390 gr, l3, u, c, s4, mcf.OPTIMAL, true, 6360, "#A9"); 391 392 // Check the GEQ form 393 mcf.reset().upperMap(u).costMap(c).supplyMap(s5); 394 checkMcf(mcf, mcf.run(), 395 gr, l1, u, c, s5, mcf.OPTIMAL, true, 3530, "#A10", GEQ); 396 mcf.supplyType(mcf.GEQ); 397 checkMcf(mcf, mcf.lowerMap(l2).run(), 398 gr, l2, u, c, s5, mcf.OPTIMAL, true, 4540, "#A11", GEQ); 399 mcf.supplyMap(s6); 400 checkMcf(mcf, mcf.run(), 401 gr, l2, u, c, s6, mcf.INFEASIBLE, false, 0, "#A12", GEQ); 402 403 // Check the LEQ form 404 mcf.reset().supplyType(mcf.LEQ); 405 mcf.upperMap(u).costMap(c).supplyMap(s6); 406 checkMcf(mcf, mcf.run(), 407 gr, l1, u, c, s6, mcf.OPTIMAL, true, 5080, "#A13", LEQ); 408 checkMcf(mcf, mcf.lowerMap(l2).run(), 409 gr, l2, u, c, s6, mcf.OPTIMAL, true, 5930, "#A14", LEQ); 410 mcf.supplyMap(s5); 411 checkMcf(mcf, mcf.run(), 412 gr, l2, u, c, s5, mcf.INFEASIBLE, false, 0, "#A15", LEQ); 413 414 // Check negative costs 415 NetworkSimplex<Digraph> neg_mcf(neg_gr); 416 neg_mcf.lowerMap(neg_l1).costMap(neg_c).supplyMap(neg_s); 417 checkMcf(neg_mcf, neg_mcf.run(), neg_gr, neg_l1, neg_u1, 418 neg_c, neg_s, neg_mcf.UNBOUNDED, false, 0, "#A16"); 419 neg_mcf.upperMap(neg_u2); 420 checkMcf(neg_mcf, neg_mcf.run(), neg_gr, neg_l1, neg_u2, 421 neg_c, neg_s, neg_mcf.OPTIMAL, true, -40000, "#A17"); 422 neg_mcf.reset().lowerMap(neg_l2).costMap(neg_c).supplyMap(neg_s); 423 checkMcf(neg_mcf, neg_mcf.run(), neg_gr, neg_l2, neg_u1, 424 neg_c, neg_s, neg_mcf.UNBOUNDED, false, 0, "#A18"); 425 426 NetworkSimplex<Digraph> negs_mcf(negs_gr); 427 negs_mcf.costMap(negs_c).supplyMap(negs_s); 428 checkMcf(negs_mcf, negs_mcf.run(), negs_gr, negs_l, negs_u, 429 negs_c, negs_s, negs_mcf.OPTIMAL, true, -300, "#A19", GEQ); 430 } 431 432 // B. Test NetworkSimplex with each pivot rule 433 { 434 NetworkSimplex<Digraph> mcf(gr); 435 mcf.supplyMap(s1).costMap(c).upperMap(u).lowerMap(l2); 436 437 checkMcf(mcf, mcf.run(NetworkSimplex<Digraph>::FIRST_ELIGIBLE), 438 gr, l2, u, c, s1, mcf.OPTIMAL, true, 5970, "#B1"); 439 checkMcf(mcf, mcf.run(NetworkSimplex<Digraph>::BEST_ELIGIBLE), 440 gr, l2, u, c, s1, mcf.OPTIMAL, true, 5970, "#B2"); 441 checkMcf(mcf, mcf.run(NetworkSimplex<Digraph>::BLOCK_SEARCH), 442 gr, l2, u, c, s1, mcf.OPTIMAL, true, 5970, "#B3"); 443 checkMcf(mcf, mcf.run(NetworkSimplex<Digraph>::CANDIDATE_LIST), 444 gr, l2, u, c, s1, mcf.OPTIMAL, true, 5970, "#B4"); 445 checkMcf(mcf, mcf.run(NetworkSimplex<Digraph>::ALTERING_LIST), 446 gr, l2, u, c, s1, mcf.OPTIMAL, true, 5970, "#B5"); 439 std::istringstream neg_inp1(test_neg1_lgf); 440 DigraphReader<Digraph>(neg1_gr, neg_inp1) 441 .arcMap("cost", neg1_c) 442 .arcMap("low1", neg1_l1) 443 .arcMap("low2", neg1_l2) 444 .nodeMap("sup", neg1_s) 445 .run(); 446 447 std::istringstream neg_inp2(test_neg2_lgf); 448 DigraphReader<Digraph>(neg2_gr, neg_inp2) 449 .arcMap("cost", neg2_c) 450 .nodeMap("sup", neg2_s) 451 .run(); 452 453 // Check the interface of NetworkSimplex 454 { 455 typedef concepts::Digraph GR; 456 checkConcept< McfClassConcept<GR, int, int>, 457 NetworkSimplex<GR> >(); 458 checkConcept< McfClassConcept<GR, double, double>, 459 NetworkSimplex<GR, double> >(); 460 checkConcept< McfClassConcept<GR, int, double>, 461 NetworkSimplex<GR, int, double> >(); 462 } 463 464 // Check the interface of CapacityScaling 465 { 466 typedef concepts::Digraph GR; 467 checkConcept< McfClassConcept<GR, int, int>, 468 CapacityScaling<GR> >(); 469 checkConcept< McfClassConcept<GR, double, double>, 470 CapacityScaling<GR, double> >(); 471 checkConcept< McfClassConcept<GR, int, double>, 472 CapacityScaling<GR, int, double> >(); 473 typedef CapacityScaling<GR>:: 474 SetHeap<concepts::Heap<int, RangeMap<int> > >::Create CAS; 475 checkConcept< McfClassConcept<GR, int, int>, CAS >(); 476 } 477 478 // Check the interface of CostScaling 479 { 480 typedef concepts::Digraph GR; 481 checkConcept< McfClassConcept<GR, int, int>, 482 CostScaling<GR> >(); 483 checkConcept< McfClassConcept<GR, double, double>, 484 CostScaling<GR, double> >(); 485 checkConcept< McfClassConcept<GR, int, double>, 486 CostScaling<GR, int, double> >(); 487 typedef CostScaling<GR>:: 488 SetLargeCost<double>::Create COS; 489 checkConcept< McfClassConcept<GR, int, int>, COS >(); 490 } 491 492 // Check the interface of CycleCanceling 493 { 494 typedef concepts::Digraph GR; 495 checkConcept< McfClassConcept<GR, int, int>, 496 CycleCanceling<GR> >(); 497 checkConcept< McfClassConcept<GR, double, double>, 498 CycleCanceling<GR, double> >(); 499 checkConcept< McfClassConcept<GR, int, double>, 500 CycleCanceling<GR, int, double> >(); 501 } 502 503 // Test NetworkSimplex 504 { 505 typedef NetworkSimplex<Digraph> MCF; 506 runMcfGeqTests<MCF>(MCF::FIRST_ELIGIBLE, "NS-FE", true); 507 runMcfLeqTests<MCF>(MCF::FIRST_ELIGIBLE, "NS-FE"); 508 runMcfGeqTests<MCF>(MCF::BEST_ELIGIBLE, "NS-BE", true); 509 runMcfLeqTests<MCF>(MCF::BEST_ELIGIBLE, "NS-BE"); 510 runMcfGeqTests<MCF>(MCF::BLOCK_SEARCH, "NS-BS", true); 511 runMcfLeqTests<MCF>(MCF::BLOCK_SEARCH, "NS-BS"); 512 runMcfGeqTests<MCF>(MCF::CANDIDATE_LIST, "NS-CL", true); 513 runMcfLeqTests<MCF>(MCF::CANDIDATE_LIST, "NS-CL"); 514 runMcfGeqTests<MCF>(MCF::ALTERING_LIST, "NS-AL", true); 515 runMcfLeqTests<MCF>(MCF::ALTERING_LIST, "NS-AL"); 516 } 517 518 // Test CapacityScaling 519 { 520 typedef CapacityScaling<Digraph> MCF; 521 runMcfGeqTests<MCF>(0, "SSP"); 522 runMcfGeqTests<MCF>(2, "CAS"); 523 } 524 525 // Test CostScaling 526 { 527 typedef CostScaling<Digraph> MCF; 528 runMcfGeqTests<MCF>(MCF::PUSH, "COS-PR"); 529 runMcfGeqTests<MCF>(MCF::AUGMENT, "COS-AR"); 530 runMcfGeqTests<MCF>(MCF::PARTIAL_AUGMENT, "COS-PAR"); 531 } 532 533 // Test CycleCanceling 534 { 535 typedef CycleCanceling<Digraph> MCF; 536 runMcfGeqTests<MCF>(MCF::SIMPLE_CYCLE_CANCELING, "SCC"); 537 runMcfGeqTests<MCF>(MCF::MINIMUM_MEAN_CYCLE_CANCELING, "MMCC"); 538 runMcfGeqTests<MCF>(MCF::CANCEL_AND_TIGHTEN, "CAT"); 447 539 } 448 540
Note: See TracChangeset
for help on using the changeset viewer.