Changeset 1008:d216e1c8b3fa in lemon-main
- Timestamp:
- 11/28/12 11:54:43 (12 years ago)
- Branch:
- default
- Parents:
- 999:00f8d9f9920d (diff), 1007:7e368d9b67f7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Phase:
- public
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/concepts/graph_components.h
r998 r1008 109 109 110 110 bool b; 111 ignore_unused_variable_warning(b); 112 111 113 b = (ia == ib) && (ia != ib); 112 114 b = (ia == INVALID) && (ib != INVALID); -
lemon/concepts/graph_components.h
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 19 19 ///\ingroup graph_concepts 20 20 ///\file 21 ///\brief The concept of graph components.21 ///\brief The concepts of graph components. 22 22 23 23 #ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H … … 39 39 /// \note This class is a template class so that we can use it to 40 40 /// create graph skeleton classes. The reason for this is that \c Node 41 /// and \c Arc (or \c Edge) types should \e not derive from the same 41 /// and \c Arc (or \c Edge) types should \e not derive from the same 42 42 /// base class. For \c Node you should instantiate it with character 43 43 /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'. … … 90 90 /// 91 91 /// This operator defines an ordering of the items. 92 /// It makes possible to use graph item types as key types in 92 /// It makes possible to use graph item types as key types in 93 93 /// associative containers (e.g. \c std::map). 94 94 /// 95 /// \note This operator only ha veto define some strict ordering of95 /// \note This operator only has to define some strict ordering of 96 96 /// the items; this order has nothing to do with the iteration 97 97 /// ordering of the items. … … 126 126 /// This class describes the base interface of directed graph types. 127 127 /// All digraph %concepts have to conform to this class. 128 /// It just provides types for nodes and arcs and functions 128 /// It just provides types for nodes and arcs and functions 129 129 /// to get the source and the target nodes of arcs. 130 130 class BaseDigraphComponent { … … 434 434 /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types. 435 435 /// 436 /// This class describes the concept of \c NodeIt, \c ArcIt and 436 /// This class describes the concept of \c NodeIt, \c ArcIt and 437 437 /// \c EdgeIt subtypes of digraph and graph types. 438 438 template <typename GR, typename Item> … … 474 474 /// next item. 475 475 GraphItemIt& operator++() { return *this; } 476 476 477 477 /// \brief Equality operator 478 478 /// … … 512 512 }; 513 513 514 /// \brief Concept class for \c InArcIt, \c OutArcIt and 514 /// \brief Concept class for \c InArcIt, \c OutArcIt and 515 515 /// \c IncEdgeIt types. 516 516 /// 517 /// This class describes the concept of \c InArcIt, \c OutArcIt 517 /// This class describes the concept of \c InArcIt, \c OutArcIt 518 518 /// and \c IncEdgeIt subtypes of digraph and graph types. 519 519 /// 520 520 /// \note Since these iterator classes do not inherit from the same 521 521 /// base class, there is an additional template parameter (selector) 522 /// \c sel. For \c InArcIt you should instantiate it with character 522 /// \c sel. For \c InArcIt you should instantiate it with character 523 523 /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'. 524 524 template <typename GR, … … 541 541 GraphIncIt(const GraphIncIt& it) : Item(it) {} 542 542 543 /// \brief Constructor that sets the iterator to the first 543 /// \brief Constructor that sets the iterator to the first 544 544 /// incoming or outgoing arc. 545 545 /// 546 /// Constructor that sets the iterator to the first arc 546 /// Constructor that sets the iterator to the first arc 547 547 /// incoming to or outgoing from the given node. 548 548 explicit GraphIncIt(const GR&, const Base&) {} … … 819 819 /// \brief Return the first edge incident to the given node. 820 820 /// 821 /// This function gives back the first edge incident to the given 821 /// This function gives back the first edge incident to the given 822 822 /// node. The bool parameter gives back the direction for which the 823 /// source node of the directed arc representing the edge is the 823 /// source node of the directed arc representing the edge is the 824 824 /// given node. 825 825 void firstInc(Edge&, bool&, const Node&) const {} … … 828 828 /// given node. 829 829 /// 830 /// This function gives back the next edge incident to the given 830 /// This function gives back the next edge incident to the given 831 831 /// node. The bool parameter should be used as \c firstInc() use it. 832 832 void nextInc(Edge&, bool&) const {} … … 1008 1008 /// 1009 1009 /// This class describes the concept of standard graph maps, i.e. 1010 /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 1010 /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 1011 1011 /// graph types, which can be used for associating data to graph items. 1012 1012 /// The standard graph maps must conform to the ReferenceMap concept. … … 1063 1063 _Map m1(g); 1064 1064 _Map m2(g,t); 1065 1065 1066 1066 // Copy constructor 1067 1067 // _Map m3(m); … … 1087 1087 /// 1088 1088 /// This class describes the interface of mappable directed graphs. 1089 /// It extends \ref BaseDigraphComponent with the standard digraph 1089 /// It extends \ref BaseDigraphComponent with the standard digraph 1090 1090 /// map classes, namely \c NodeMap and \c ArcMap. 1091 1091 /// This concept is part of the Digraph concept. … … 1225 1225 /// 1226 1226 /// This class describes the interface of mappable undirected graphs. 1227 /// It extends \ref MappableDigraphComponent with the standard graph 1227 /// It extends \ref MappableDigraphComponent with the standard graph 1228 1228 /// map class for edges (\c EdgeMap). 1229 1229 /// This concept is part of the Graph concept. … … 1311 1311 /// 1312 1312 /// This class describes the interface of extendable directed graphs. 1313 /// It extends \ref BaseDigraphComponent with functions for adding 1313 /// It extends \ref BaseDigraphComponent with functions for adding 1314 1314 /// nodes and arcs to the digraph. 1315 1315 /// This concept requires \ref AlterableDigraphComponent. … … 1356 1356 /// 1357 1357 /// This class describes the interface of extendable undirected graphs. 1358 /// It extends \ref BaseGraphComponent with functions for adding 1358 /// It extends \ref BaseGraphComponent with functions for adding 1359 1359 /// nodes and edges to the graph. 1360 1360 /// This concept requires \ref AlterableGraphComponent. … … 1401 1401 /// 1402 1402 /// This class describes the interface of erasable directed graphs. 1403 /// It extends \ref BaseDigraphComponent with functions for removing 1403 /// It extends \ref BaseDigraphComponent with functions for removing 1404 1404 /// nodes and arcs from the digraph. 1405 1405 /// This concept requires \ref AlterableDigraphComponent. … … 1414 1414 /// \brief Erase a node from the digraph. 1415 1415 /// 1416 /// This function erases the given node from the digraph and all arcs 1416 /// This function erases the given node from the digraph and all arcs 1417 1417 /// connected to the node. 1418 1418 void erase(const Node&) {} … … 1441 1441 /// 1442 1442 /// This class describes the interface of erasable undirected graphs. 1443 /// It extends \ref BaseGraphComponent with functions for removing 1443 /// It extends \ref BaseGraphComponent with functions for removing 1444 1444 /// nodes and edges from the graph. 1445 1445 /// This concept requires \ref AlterableGraphComponent. -
test/bfs_test.cc
r877 r1008 62 62 Arc e; 63 63 int l, i; 64 ignore_unused_variable_warning(l,i); 64 65 bool b; 65 66 BType::DistMap d(G); … … 151 152 Digraph g; 152 153 bool b; 154 ignore_unused_variable_warning(b); 155 153 156 bfs(g).run(Node()); 154 157 b=bfs(g).run(Node(),Node()); -
test/bfs_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 85 85 b = const_bfs_test.emptyQueue(); 86 86 i = const_bfs_test.queueSize(); 87 87 88 88 bfs_test.start(); 89 89 bfs_test.start(t); … … 106 106 ::SetProcessedMap<concepts::WriteMap<Node,bool> > 107 107 ::Create bfs_test(G); 108 108 109 109 concepts::ReadWriteMap<Node,Arc> pred_map; 110 110 concepts::ReadWriteMap<Node,int> dist_map; 111 111 concepts::ReadWriteMap<Node,bool> reached_map; 112 112 concepts::WriteMap<Node,bool> processed_map; 113 113 114 114 bfs_test 115 115 .predMap(pred_map) … … 121 121 bfs_test.run(s,t); 122 122 bfs_test.run(); 123 123 124 124 bfs_test.init(); 125 125 bfs_test.addSource(s); … … 130 130 b = bfs_test.emptyQueue(); 131 131 i = bfs_test.queueSize(); 132 132 133 133 bfs_test.start(); 134 134 bfs_test.start(t); -
test/circulation_test.cc
r877 r1008 74 74 VType v; 75 75 bool b; 76 ignore_unused_variable_warning(v,b); 76 77 77 78 typedef Circulation<Digraph, CapMap, CapMap, SupplyMap> -
test/circulation_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 83 83 CirculationType circ_test(g, lcap, ucap, supply); 84 84 const CirculationType& const_circ_test = circ_test; 85 85 86 86 circ_test 87 87 .lowerMap(lcap) … … 89 89 .supplyMap(supply) 90 90 .flowMap(flow); 91 92 const CirculationType::Elevator& elev = const_circ_test.elevator(); 93 circ_test.elevator(const_cast<CirculationType::Elevator&>(elev)); 94 CirculationType::Tolerance tol = const_circ_test.tolerance(); 95 circ_test.tolerance(tol); 91 96 92 97 circ_test.init(); … … 99 104 b = const_circ_test.barrier(n); 100 105 const_circ_test.barrierMap(bar); 101 106 102 107 ignore_unused_variable_warning(fm); 103 108 } -
test/dfs_test.cc
r964 r1008 68 68 int l, i; 69 69 bool b; 70 ignore_unused_variable_warning(l,i,b); 71 70 72 DType::DistMap d(G); 71 73 DType::PredMap p(G); … … 152 154 Digraph g; 153 155 bool b; 156 ignore_unused_variable_warning(b); 157 154 158 dfs(g).run(Node()); 155 159 b=dfs(g).run(Node(),Node()); -
test/dfs_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 89 89 b = const_dfs_test.emptyQueue(); 90 90 i = const_dfs_test.queueSize(); 91 91 92 92 dfs_test.start(); 93 93 dfs_test.start(t); … … 115 115 concepts::ReadWriteMap<Node,bool> reached_map; 116 116 concepts::WriteMap<Node,bool> processed_map; 117 117 118 118 dfs_test 119 119 .predMap(pred_map) … … 132 132 b = dfs_test.emptyQueue(); 133 133 i = dfs_test.queueSize(); 134 134 135 135 dfs_test.start(); 136 136 dfs_test.start(t); -
test/dijkstra_test.cc
r877 r1008 66 66 int i; 67 67 bool b; 68 ignore_unused_variable_warning(l,i,b); 69 68 70 DType::DistMap d(G); 69 71 DType::PredMap p(G); … … 163 165 Digraph g; 164 166 bool b; 167 ignore_unused_variable_warning(b); 168 165 169 dijkstra(g,LengthMap()).run(Node()); 166 170 b=dijkstra(g,LengthMap()).run(Node(),Node()); -
test/dijkstra_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 88 88 b = const_dijkstra_test.emptyQueue(); 89 89 i = const_dijkstra_test.queueSize(); 90 90 91 91 dijkstra_test.start(); 92 92 dijkstra_test.start(t); … … 112 112 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 113 113 ::SetStandardHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 114 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, 114 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, 115 115 concepts::ReadWriteMap<Node,int> > 116 116 ::Create dijkstra_test(G,length); … … 122 122 concepts::ReadWriteMap<Node,int> heap_cross_ref; 123 123 BinHeap<VType, concepts::ReadWriteMap<Node,int> > heap(heap_cross_ref); 124 124 125 125 dijkstra_test 126 126 .lengthMap(length_map) … … 139 139 b = dijkstra_test.emptyQueue(); 140 140 i = dijkstra_test.queueSize(); 141 141 142 142 dijkstra_test.start(); 143 143 dijkstra_test.start(t); -
test/gomory_hu_test.cc
r877 r1008 69 69 Value v; 70 70 int d; 71 ignore_unused_variable_warning(v,d); 71 72 72 73 GomoryHu<Graph, CapMap> gh_test(g, cap); -
test/gomory_hu_test.cc
r1007 r1008 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 * 5 * Copyright (C) 2003-2010 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 * 9 * Permission to use, modify and distribute this software is granted 10 * provided that this copyright notice appears in all copies. For 11 * precise terms see the accompanying LICENSE file. 12 * 13 * This software is provided "AS IS" with no warranty of any kind, 14 * express or implied, and with no claim as to its suitability for any 15 * purpose. 16 * 17 */ 18 1 19 #include <iostream> 2 20 … … 34 52 "source 0\n" 35 53 "target 3\n"; 36 54 37 55 void checkGomoryHuCompile() 38 56 { … … 71 89 72 90 int cutValue(const Graph& graph, const BoolNodeMap& cut, 73 91 const IntEdgeMap& capacity) { 74 92 75 93 int sum = 0; … … 109 127 int sum=0; 110 128 for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a) 111 sum+=capacity[a]; 129 sum+=capacity[a]; 112 130 check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt"); 113 131 … … 120 138 } 121 139 } 122 140 123 141 return 0; 124 142 } -
test/hao_orlin_test.cc
r877 r1008 67 67 CutMap cut; 68 68 Value v; 69 ignore_unused_variable_warning(v); 69 70 70 71 HaoOrlin<Digraph, CapMap> ho_test(g, cap); -
test/hao_orlin_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 85 85 86 86 template <typename Graph, typename CapMap, typename CutMap> 87 typename CapMap::Value 87 typename CapMap::Value 88 88 cutValue(const Graph& graph, const CapMap& cap, const CutMap& cut) 89 89 { … … 112 112 ho.run(); 113 113 ho.minCutMap(cut); 114 114 115 115 check(ho.minCutValue() == 1, "Wrong cut value"); 116 116 check(ho.minCutValue() == cutValue(graph, cap1, cut), "Wrong cut value"); … … 128 128 ho.run(); 129 129 ho.minCutMap(cut); 130 130 131 131 check(ho.minCutValue() == 1, "Wrong cut value"); 132 132 check(ho.minCutValue() == cutValue(graph, cap3, cut), "Wrong cut value"); 133 133 } 134 134 135 135 typedef Undirector<SmartDigraph> UGraph; 136 136 UGraph ugraph(graph); 137 137 138 138 { 139 139 HaoOrlin<UGraph, SmartDigraph::ArcMap<int> > ho(ugraph, cap1); 140 140 ho.run(); 141 141 ho.minCutMap(cut); 142 142 143 143 check(ho.minCutValue() == 2, "Wrong cut value"); 144 144 check(ho.minCutValue() == cutValue(ugraph, cap1, cut), "Wrong cut value"); … … 148 148 ho.run(); 149 149 ho.minCutMap(cut); 150 150 151 151 check(ho.minCutValue() == 5, "Wrong cut value"); 152 152 check(ho.minCutValue() == cutValue(ugraph, cap2, cut), "Wrong cut value"); … … 156 156 ho.run(); 157 157 ho.minCutMap(cut); 158 158 159 159 check(ho.minCutValue() == 5, "Wrong cut value"); 160 160 check(ho.minCutValue() == cutValue(ugraph, cap3, cut), "Wrong cut value"); -
test/matching_test.cc
r877 r1008 146 146 MaxMatching<Graph>::Status stat = 147 147 const_mat_test.status(n); 148 ignore_unused_variable_warning(stat); 148 149 const MaxMatching<Graph>::StatusMap& smap = 149 150 const_mat_test.statusMap(); -
test/matching_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 135 135 mat_test.startDense(); 136 136 mat_test.run(); 137 137 138 138 const_mat_test.matchingSize(); 139 139 const_mat_test.matching(e); … … 144 144 const_mat_test.mate(n); 145 145 146 MaxMatching<Graph>::Status stat = 146 MaxMatching<Graph>::Status stat = 147 147 const_mat_test.status(n); 148 148 ignore_unused_variable_warning(stat); … … 172 172 mat_test.start(); 173 173 mat_test.run(); 174 174 175 175 const_mat_test.matchingWeight(); 176 176 const_mat_test.matchingSize(); … … 181 181 e = mmap[n]; 182 182 const_mat_test.mate(n); 183 183 184 184 int k = 0; 185 185 const_mat_test.dualValue(); … … 209 209 mat_test.start(); 210 210 mat_test.run(); 211 211 212 212 const_mat_test.matchingWeight(); 213 213 const_mat_test.matching(e); … … 217 217 e = mmap[n]; 218 218 const_mat_test.mate(n); 219 219 220 220 int k = 0; 221 221 const_mat_test.dualValue(); … … 403 403 edgeMap("weight", weight).run(); 404 404 405 MaxMatching<SmartGraph> mm(graph); 406 mm.run(); 407 checkMatching(graph, mm); 408 409 MaxWeightedMatching<SmartGraph> mwm(graph, weight); 410 mwm.run(); 411 checkWeightedMatching(graph, weight, mwm); 412 413 MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight); 414 bool perfect = mwpm.run(); 415 416 check(perfect == (mm.matchingSize() * 2 == countNodes(graph)), 417 "Perfect matching found"); 418 419 if (perfect) { 420 checkWeightedPerfectMatching(graph, weight, mwpm); 405 bool perfect; 406 { 407 MaxMatching<SmartGraph> mm(graph); 408 mm.run(); 409 checkMatching(graph, mm); 410 perfect = 2 * mm.matchingSize() == countNodes(graph); 411 } 412 413 { 414 MaxWeightedMatching<SmartGraph> mwm(graph, weight); 415 mwm.run(); 416 checkWeightedMatching(graph, weight, mwm); 417 } 418 419 { 420 MaxWeightedMatching<SmartGraph> mwm(graph, weight); 421 mwm.init(); 422 mwm.start(); 423 checkWeightedMatching(graph, weight, mwm); 424 } 425 426 { 427 MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight); 428 bool result = mwpm.run(); 429 430 check(result == perfect, "Perfect matching found"); 431 if (perfect) { 432 checkWeightedPerfectMatching(graph, weight, mwpm); 433 } 434 } 435 436 { 437 MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight); 438 mwpm.init(); 439 bool result = mwpm.start(); 440 441 check(result == perfect, "Perfect matching found"); 442 if (perfect) { 443 checkWeightedPerfectMatching(graph, weight, mwpm); 444 } 421 445 } 422 446 } -
test/min_cost_arborescence_test.cc
r877 r1008 92 92 VType c; 93 93 bool b; 94 ignore_unused_variable_warning(c,b); 94 95 int i; 95 96 CostMap cost; -
test/min_cost_arborescence_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 085 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 112 112 b = const_mcarb_test.emptyQueue(); 113 113 i = const_mcarb_test.queueSize(); 114 114 115 115 c = const_mcarb_test.arborescenceCost(); 116 116 b = const_mcarb_test.arborescence(e); … … 122 122 b = const_mcarb_test.reached(n); 123 123 b = const_mcarb_test.processed(n); 124 124 125 125 i = const_mcarb_test.dualNum(); 126 126 c = const_mcarb_test.dualValue(); 127 127 i = const_mcarb_test.dualSize(i); 128 128 c = const_mcarb_test.dualValue(i); 129 129 130 130 ignore_unused_variable_warning(am); 131 131 ignore_unused_variable_warning(pm); -
test/preflow_test.cc
r924 r1008 87 87 VType v; 88 88 bool b; 89 ignore_unused_variable_warning(v,b); 89 90 90 91 typedef Preflow<Digraph, CapMap> -
test/preflow_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 97 97 const PreflowType& const_preflow_test = preflow_test; 98 98 99 const PreflowType::Elevator& elev = const_preflow_test.elevator(); 100 preflow_test.elevator(const_cast<PreflowType::Elevator&>(elev)); 101 PreflowType::Tolerance tol = const_preflow_test.tolerance(); 102 preflow_test.tolerance(tol); 103 99 104 preflow_test 100 105 .capacityMap(cap) … … 115 120 b = const_preflow_test.minCut(n); 116 121 const_preflow_test.minCutMap(cut); 117 122 118 123 ignore_unused_variable_warning(fm); 119 124 } -
test/suurballe_test.cc
r877 r1008 118 118 int f; 119 119 VType c; 120 ignore_unused_variable_warning(f,c); 121 120 122 c = const_suurb_test.totalLength(); 121 123 f = const_suurb_test.flow(e); -
test/suurballe_test.cc
r1007 r1008 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 24 24 #include <lemon/suurballe.h> 25 25 #include <lemon/concepts/digraph.h> 26 #include <lemon/concepts/heap.h> 26 27 27 28 #include "test_tools.h" … … 81 82 typedef Digraph::Arc Arc; 82 83 typedef concepts::ReadMap<Arc, VType> LengthMap; 83 84 typedef Suurballe<Digraph, LengthMap> SuurballeType; 84 85 typedef Suurballe<Digraph, LengthMap> ST; 86 typedef Suurballe<Digraph, LengthMap> 87 ::SetFlowMap<ST::FlowMap> 88 ::SetPotentialMap<ST::PotentialMap> 89 ::SetPath<SimplePath<Digraph> > 90 ::SetHeap<concepts::Heap<VType, Digraph::NodeMap<int> > > 91 ::Create SuurballeType; 85 92 86 93 Digraph g; … … 102 109 k = suurb_test.run(n, n, k); 103 110 suurb_test.init(n); 111 suurb_test.fullInit(n); 112 suurb_test.start(n); 113 suurb_test.start(n, k); 104 114 k = suurb_test.findFlow(n); 105 115 k = suurb_test.findFlow(n, k); 106 116 suurb_test.findPaths(); 107 117 108 118 int f; 109 119 VType c; … … 119 129 k = const_suurb_test.pathNum(); 120 130 Path<Digraph> p = const_suurb_test.path(k); 121 131 122 132 ignore_unused_variable_warning(fm); 123 133 ignore_unused_variable_warning(pm); … … 198 208 run(); 199 209 200 // Find 2 paths210 // Check run() 201 211 { 202 212 Suurballe<ListDigraph> suurballe(digraph, length); 213 214 // Find 2 paths 203 215 check(suurballe.run(s, t) == 2, "Wrong number of paths"); 204 216 check(checkFlow(digraph, suurballe.flowMap(), s, t, 2), … … 210 222 for (int i = 0; i < suurballe.pathNum(); ++i) 211 223 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 212 } 213 214 // Find 3 paths 215 { 216 Suurballe<ListDigraph> suurballe(digraph, length); 224 225 // Find 3 paths 217 226 check(suurballe.run(s, t, 3) == 3, "Wrong number of paths"); 218 227 check(checkFlow(digraph, suurballe.flowMap(), s, t, 3), … … 224 233 for (int i = 0; i < suurballe.pathNum(); ++i) 225 234 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 226 } 227 228 // Find 5 paths (only 3 can be found) 229 { 230 Suurballe<ListDigraph> suurballe(digraph, length); 235 236 // Find 5 paths (only 3 can be found) 231 237 check(suurballe.run(s, t, 5) == 3, "Wrong number of paths"); 232 238 check(checkFlow(digraph, suurballe.flowMap(), s, t, 3), … … 240 246 } 241 247 248 // Check fullInit() + start() 249 { 250 Suurballe<ListDigraph> suurballe(digraph, length); 251 suurballe.fullInit(s); 252 253 // Find 2 paths 254 check(suurballe.start(t) == 2, "Wrong number of paths"); 255 check(suurballe.totalLength() == 510, "The flow is not optimal"); 256 257 // Find 3 paths 258 check(suurballe.start(t, 3) == 3, "Wrong number of paths"); 259 check(suurballe.totalLength() == 1040, "The flow is not optimal"); 260 261 // Find 5 paths (only 3 can be found) 262 check(suurballe.start(t, 5) == 3, "Wrong number of paths"); 263 check(suurballe.totalLength() == 1040, "The flow is not optimal"); 264 } 265 242 266 return 0; 243 267 } -
tools/dimacs-solver.cc
r877 r1006 118 118 if (report) std::cerr << "Read the file: " << ti << '\n'; 119 119 120 ti.restart(); 121 NetworkSimplex<Digraph, Value> ns(g); 120 typedef NetworkSimplex<Digraph, Value> MCF; 121 ti.restart(); 122 MCF ns(g); 122 123 ns.lowerMap(lower).upperMap(cap).costMap(cost).supplyMap(sup); 123 124 if (sum_sup > 0) ns.supplyType(ns.LEQ); 124 125 if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n'; 125 126 ti.restart(); 126 boolres = ns.run();127 typename MCF::ProblemType res = ns.run(); 127 128 if (report) { 128 129 std::cerr << "Run NetworkSimplex: " << ti << "\n\n"; 129 std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n';130 std::cerr << "Feasible flow: " << (res == MCF::OPTIMAL ? "found" : "not found") << '\n'; 130 131 if (res) std::cerr << "Min flow cost: " 131 132 << ns.template totalCost<LargeValue>() << '\n'; … … 188 189 189 190 int main(int argc, const char *argv[]) { 190 typedef SmartDigraph Digraph;191 192 typedef Digraph::Arc Arc;193 191 194 192 std::string inputName; -
tools/dimacs-solver.cc
r1005 r1006 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 89 89 pre.run(); 90 90 if(report) std::cerr << "Run Preflow: " << ti << '\n'; 91 if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n'; 92 } 93 94 template<class Value >91 if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n'; 92 } 93 94 template<class Value, class LargeValue> 95 95 void solve_min(ArgParser &ap, std::istream &is, std::ostream &, 96 96 Value infty, DimacsDescriptor &desc) … … 129 129 std::cerr << "Run NetworkSimplex: " << ti << "\n\n"; 130 130 std::cerr << "Feasible flow: " << (res == MCF::OPTIMAL ? "found" : "not found") << '\n'; 131 if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n'; 131 if (res) std::cerr << "Min flow cost: " 132 << ns.template totalCost<LargeValue>() << '\n'; 132 133 } 133 134 } … … 149 150 if(report) std::cerr << "Run MaxMatching: " << ti << '\n'; 150 151 if(report) std::cerr << "\nCardinality of max matching: " 151 << mat.matchingSize() << '\n'; 152 } 153 154 155 template<class Value >152 << mat.matchingSize() << '\n'; 153 } 154 155 156 template<class Value, class LargeValue> 156 157 void solve(ArgParser &ap, std::istream &is, std::ostream &os, 157 158 DimacsDescriptor &desc) … … 167 168 exit(1); 168 169 } 169 170 170 171 switch(desc.type) 171 172 { 172 173 case DimacsDescriptor::MIN: 173 solve_min<Value >(ap,is,os,infty,desc);174 solve_min<Value, LargeValue>(ap,is,os,infty,desc); 174 175 break; 175 176 case DimacsDescriptor::MAX: … … 236 237 237 238 DimacsDescriptor desc = dimacsType(is); 238 239 239 240 if(!ap.given("q")) 240 241 { … … 261 262 std::cout << "\n\n"; 262 263 } 263 264 264 265 if(ap.given("double")) 265 solve<double >(ap,is,os,desc);266 solve<double, double>(ap,is,os,desc); 266 267 else if(ap.given("ldouble")) 267 solve<long double >(ap,is,os,desc);268 solve<long double, long double>(ap,is,os,desc); 268 269 #ifdef LEMON_HAVE_LONG_LONG 269 270 else if(ap.given("long")) 270 solve<long long>(ap,is,os,desc); 271 solve<long long, long long>(ap,is,os,desc); 272 else solve<int, long long>(ap,is,os,desc); 273 #else 274 else solve<int, long>(ap,is,os,desc); 271 275 #endif 272 else solve<int>(ap,is,os,desc);273 276 274 277 return 0;
Note: See TracChangeset
for help on using the changeset viewer.