Changeset 877:141f9c0db4a3 in lemon-main for test
- Timestamp:
- 03/06/10 15:35:12 (15 years ago)
- Branch:
- default
- Children:
- 879:38213abd2911, 931:f112c18bc304
- Phase:
- public
- Location:
- test
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
test/bellman_ford_test.cc
r844 r877 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). … … 98 98 pp = const_bf_test.path(t); 99 99 pp = const_bf_test.negativeCycle(); 100 100 101 101 for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {} 102 102 } … … 111 111 concepts::ReadWriteMap<Node,Arc> pred_map; 112 112 concepts::ReadWriteMap<Node,Value> dist_map; 113 113 114 114 bf_test 115 115 .lengthMap(length_map) … … 190 190 check(pathSource(gr, p) == s, "path() found a wrong path."); 191 191 check(pathTarget(gr, p) == t, "path() found a wrong path."); 192 192 193 193 ListPath<Digraph> path; 194 194 Value dist; … … 229 229 SmartDigraph gr; 230 230 IntArcMap length(gr); 231 231 232 232 Node n1 = gr.addNode(); 233 233 Node n2 = gr.addNode(); 234 234 Node n3 = gr.addNode(); 235 235 Node n4 = gr.addNode(); 236 236 237 237 Arc a1 = gr.addArc(n1, n2); 238 238 Arc a2 = gr.addArc(n2, n2); 239 239 240 240 length[a1] = 2; 241 241 length[a2] = -1; 242 242 243 243 { 244 244 BellmanFord<SmartDigraph, IntArcMap> bf(gr, length); … … 248 248 "Wrong negative cycle."); 249 249 } 250 250 251 251 length[a2] = 0; 252 252 253 253 { 254 254 BellmanFord<SmartDigraph, IntArcMap> bf(gr, length); … … 257 257 "Negative cycle should not be found."); 258 258 } 259 259 260 260 length[gr.addArc(n1, n3)] = 5; 261 261 length[gr.addArc(n4, n3)] = 1; 262 262 length[gr.addArc(n2, n4)] = 2; 263 263 length[gr.addArc(n3, n2)] = -4; 264 264 265 265 { 266 266 BellmanFord<SmartDigraph, IntArcMap> bf(gr, length); -
test/bfs_test.cc
r585 r877 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). … … 84 84 b = const_bfs_test.emptyQueue(); 85 85 i = const_bfs_test.queueSize(); 86 86 87 87 bfs_test.start(); 88 88 bfs_test.start(t); … … 105 105 ::SetProcessedMap<concepts::WriteMap<Node,bool> > 106 106 ::Create bfs_test(G); 107 107 108 108 concepts::ReadWriteMap<Node,Arc> pred_map; 109 109 concepts::ReadWriteMap<Node,int> dist_map; 110 110 concepts::ReadWriteMap<Node,bool> reached_map; 111 111 concepts::WriteMap<Node,bool> processed_map; 112 112 113 113 bfs_test 114 114 .predMap(pred_map) … … 120 120 bfs_test.run(s,t); 121 121 bfs_test.run(); 122 122 123 123 bfs_test.init(); 124 124 bfs_test.addSource(s); … … 129 129 b = bfs_test.emptyQueue(); 130 130 i = bfs_test.queueSize(); 131 131 132 132 bfs_test.start(); 133 133 bfs_test.start(t); -
test/circulation_test.cc
r689 r877 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). … … 82 82 CirculationType circ_test(g, lcap, ucap, supply); 83 83 const CirculationType& const_circ_test = circ_test; 84 84 85 85 circ_test 86 86 .lowerMap(lcap) … … 88 88 .supplyMap(supply) 89 89 .flowMap(flow); 90 90 91 91 const CirculationType::Elevator& elev = const_circ_test.elevator(); 92 92 circ_test.elevator(const_cast<CirculationType::Elevator&>(elev)); … … 103 103 b = const_circ_test.barrier(n); 104 104 const_circ_test.barrierMap(bar); 105 105 106 106 ignore_unused_variable_warning(fm); 107 107 } -
test/connectivity_test.cc
r649 r877 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). … … 30 30 typedef ListDigraph Digraph; 31 31 typedef Undirector<Digraph> Graph; 32 33 { 34 Digraph d; 35 Digraph::NodeMap<int> order(d); 36 Graph g(d); 37 32 33 { 34 Digraph d; 35 Digraph::NodeMap<int> order(d); 36 Graph g(d); 37 38 38 check(stronglyConnected(d), "The empty digraph is strongly connected"); 39 39 check(countStronglyConnectedComponents(d) == 0, … … 49 49 check(countBiEdgeConnectedComponents(g) == 0, 50 50 "The empty graph has 0 bi-edge-connected component"); 51 51 52 52 check(dag(d), "The empty digraph is DAG."); 53 53 check(checkedTopologicalSort(d, order), "The empty digraph is DAG."); … … 83 83 check(countBiEdgeConnectedComponents(g) == 1, 84 84 "This graph has 1 bi-edge-connected component"); 85 85 86 86 check(dag(d), "This digraph is DAG."); 87 87 check(checkedTopologicalSort(d, order), "This digraph is DAG."); … … 102 102 Digraph::NodeMap<int> order(d); 103 103 Graph g(d); 104 104 105 105 Digraph::Node n1 = d.addNode(); 106 106 Digraph::Node n2 = d.addNode(); … … 109 109 Digraph::Node n5 = d.addNode(); 110 110 Digraph::Node n6 = d.addNode(); 111 111 112 112 d.addArc(n1, n3); 113 113 d.addArc(n3, n2); … … 137 137 check(!parallelFree(g), "This graph is not parallel-free."); 138 138 check(!simpleGraph(g), "This graph is not simple."); 139 139 140 140 d.addArc(n3, n3); 141 141 142 142 check(!loopFree(d), "This digraph is not loop-free."); 143 143 check(!loopFree(g), "This graph is not loop-free."); 144 144 check(!simpleGraph(d), "This digraph is not simple."); 145 145 146 146 d.addArc(n3, n2); 147 147 148 148 check(!parallelFree(d), "This digraph is not parallel-free."); 149 149 } 150 150 151 151 { 152 152 Digraph d; 153 153 Digraph::ArcMap<bool> cutarcs(d, false); 154 154 Graph g(d); 155 155 156 156 Digraph::Node n1 = d.addNode(); 157 157 Digraph::Node n2 = d.addNode(); … … 173 173 d.addArc(n6, n7); 174 174 d.addArc(n7, n6); 175 175 176 176 check(!stronglyConnected(d), "This digraph is not strongly connected"); 177 177 check(countStronglyConnectedComponents(d) == 3, … … 236 236 Digraph d; 237 237 Digraph::NodeMap<int> order(d); 238 238 239 239 Digraph::Node belt = d.addNode(); 240 240 Digraph::Node trousers = d.addNode(); … … 256 256 d.addArc(shirt, necktie); 257 257 d.addArc(necktie, coat); 258 258 259 259 check(dag(d), "This digraph is DAG."); 260 260 topologicalSort(d, order); … … 268 268 ListGraph g; 269 269 ListGraph::NodeMap<bool> map(g); 270 270 271 271 ListGraph::Node n1 = g.addNode(); 272 272 ListGraph::Node n2 = g.addNode(); … … 284 284 g.addEdge(n4, n7); 285 285 g.addEdge(n5, n7); 286 286 287 287 check(bipartite(g), "This graph is bipartite"); 288 288 check(bipartitePartitions(g, map), "This graph is bipartite"); 289 289 290 290 check(map[n1] == map[n2] && map[n1] == map[n6] && map[n1] == map[n7], 291 291 "Wrong bipartitePartitions()"); -
test/dfs_test.cc
r585 r877 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). … … 84 84 b = const_dfs_test.emptyQueue(); 85 85 i = const_dfs_test.queueSize(); 86 86 87 87 dfs_test.start(); 88 88 dfs_test.start(t); … … 110 110 concepts::ReadWriteMap<Node,bool> reached_map; 111 111 concepts::WriteMap<Node,bool> processed_map; 112 112 113 113 dfs_test 114 114 .predMap(pred_map) … … 127 127 b = dfs_test.emptyQueue(); 128 128 i = dfs_test.queueSize(); 129 129 130 130 dfs_test.start(); 131 131 dfs_test.start(t); -
test/digraph_test.cc
r780 r877 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). … … 393 393 SmartDigraph::NodeMap<StaticDigraph::Node> nref(g); 394 394 SmartDigraph::ArcMap<StaticDigraph::Arc> aref(g); 395 395 396 396 StaticDigraph G; 397 397 398 398 checkGraphNodeList(G, 0); 399 399 checkGraphArcList(G, 0); … … 465 465 466 466 G.build(6, arcs.begin(), arcs.end()); 467 467 468 468 checkGraphNodeList(G, 6); 469 469 checkGraphArcList(G, 9); … … 489 489 checkGraphNodeMap(G); 490 490 checkGraphArcMap(G); 491 491 492 492 int n = G.nodeNum(); 493 493 int m = G.arcNum(); -
test/dijkstra_test.cc
r585 r877 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). … … 86 86 b = const_dijkstra_test.emptyQueue(); 87 87 i = const_dijkstra_test.queueSize(); 88 88 89 89 dijkstra_test.start(); 90 90 dijkstra_test.start(t); … … 110 110 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 111 111 ::SetStandardHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > 112 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, 112 ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, 113 113 concepts::ReadWriteMap<Node,int> > 114 114 ::Create dijkstra_test(G,length); … … 120 120 concepts::ReadWriteMap<Node,int> heap_cross_ref; 121 121 BinHeap<VType, concepts::ReadWriteMap<Node,int> > heap(heap_cross_ref); 122 122 123 123 dijkstra_test 124 124 .lengthMap(length_map) … … 137 137 b = dijkstra_test.emptyQueue(); 138 138 i = dijkstra_test.queueSize(); 139 139 140 140 dijkstra_test.start(); 141 141 dijkstra_test.start(t); -
test/edge_set_test.cc
r488 r877 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). -
test/euler_test.cc
r592 r877 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). … … 86 86 typedef ListDigraph Digraph; 87 87 typedef Undirector<Digraph> Graph; 88 89 { 90 Digraph d; 91 Graph g(d); 92 88 89 { 90 Digraph d; 91 Graph g(d); 92 93 93 checkDiEulerIt(d); 94 94 checkDiEulerIt(g); … … 129 129 Digraph::Node n2 = d.addNode(); 130 130 Digraph::Node n3 = d.addNode(); 131 131 132 132 d.addArc(n1, n2); 133 133 d.addArc(n2, n1); … … 154 154 Digraph::Node n5 = d.addNode(); 155 155 Digraph::Node n6 = d.addNode(); 156 156 157 157 d.addArc(n1, n2); 158 158 d.addArc(n2, n4); … … 190 190 Digraph::Node n4 = d.addNode(); 191 191 Digraph::Node n5 = d.addNode(); 192 192 193 193 d.addArc(n1, n2); 194 194 d.addArc(n2, n3); … … 212 212 Digraph::Node n2 = d.addNode(); 213 213 Digraph::Node n3 = d.addNode(); 214 214 215 215 d.addArc(n1, n2); 216 216 d.addArc(n2, n3); -
test/fractional_matching_test.cc
r872 r877 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). … … 239 239 for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) { 240 240 check((e == mfm.matching(graph.u(e)) ? 1 : 0) + 241 (e == mfm.matching(graph.v(e)) ? 1 : 0) == 241 (e == mfm.matching(graph.v(e)) ? 1 : 0) == 242 242 mfm.matching(e), "Invalid matching"); 243 243 } … … 293 293 for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) { 294 294 check((e == mfm.matching(graph.u(e)) ? 1 : 0) + 295 (e == mfm.matching(graph.v(e)) ? 1 : 0) == 295 (e == mfm.matching(graph.v(e)) ? 1 : 0) == 296 296 mfm.matching(e), "Invalid matching"); 297 297 } … … 351 351 for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) { 352 352 check((e == mwfm.matching(graph.u(e)) ? 1 : 0) + 353 (e == mwfm.matching(graph.v(e)) ? 1 : 0) == 353 (e == mwfm.matching(graph.v(e)) ? 1 : 0) == 354 354 mwfm.matching(e), "Invalid matching"); 355 355 } … … 411 411 for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) { 412 412 check((e == mwpfm.matching(graph.u(e)) ? 1 : 0) + 413 (e == mwpfm.matching(graph.v(e)) ? 1 : 0) == 413 (e == mwpfm.matching(graph.v(e)) ? 1 : 0) == 414 414 mwpfm.matching(e), "Invalid matching"); 415 415 } -
test/gomory_hu_test.cc
r596 r877 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 { … … 70 88 71 89 int cutValue(const Graph& graph, const BoolNodeMap& cut, 72 90 const IntEdgeMap& capacity) { 73 91 74 92 int sum = 0; … … 108 126 int sum=0; 109 127 for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a) 110 sum+=capacity[a]; 128 sum+=capacity[a]; 111 129 check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt"); 112 130 … … 119 137 } 120 138 } 121 139 122 140 return 0; 123 141 } -
test/graph_test.cc
r740 r877 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). … … 265 265 checkGraphEdgeList(G, 3); 266 266 checkGraphArcList(G, 6); 267 267 268 268 G.addEdge(G.addNode(), G.addNode()); 269 269 … … 514 514 G.resize(dim); 515 515 check(G.dimension() == dim, "Wrong dimension"); 516 516 517 517 checkGraphNodeList(G, 1 << dim); 518 518 checkGraphEdgeList(G, dim * (1 << (dim-1))); -
test/hao_orlin_test.cc
r597 r877 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). … … 84 84 85 85 template <typename Graph, typename CapMap, typename CutMap> 86 typename CapMap::Value 86 typename CapMap::Value 87 87 cutValue(const Graph& graph, const CapMap& cap, const CutMap& cut) 88 88 { … … 111 111 ho.run(); 112 112 ho.minCutMap(cut); 113 113 114 114 check(ho.minCutValue() == 1, "Wrong cut value"); 115 115 check(ho.minCutValue() == cutValue(graph, cap1, cut), "Wrong cut value"); … … 127 127 ho.run(); 128 128 ho.minCutMap(cut); 129 129 130 130 check(ho.minCutValue() == 1, "Wrong cut value"); 131 131 check(ho.minCutValue() == cutValue(graph, cap3, cut), "Wrong cut value"); 132 132 } 133 133 134 134 typedef Undirector<SmartDigraph> UGraph; 135 135 UGraph ugraph(graph); 136 136 137 137 { 138 138 HaoOrlin<UGraph, SmartDigraph::ArcMap<int> > ho(ugraph, cap1); 139 139 ho.run(); 140 140 ho.minCutMap(cut); 141 141 142 142 check(ho.minCutValue() == 2, "Wrong cut value"); 143 143 check(ho.minCutValue() == cutValue(ugraph, cap1, cut), "Wrong cut value"); … … 147 147 ho.run(); 148 148 ho.minCutMap(cut); 149 149 150 150 check(ho.minCutValue() == 5, "Wrong cut value"); 151 151 check(ho.minCutValue() == cutValue(ugraph, cap2, cut), "Wrong cut value"); … … 155 155 ho.run(); 156 156 ho.minCutMap(cut); 157 157 158 158 check(ho.minCutValue() == 5, "Wrong cut value"); 159 159 check(ho.minCutValue() == cutValue(ugraph, cap3, cut), "Wrong cut value"); -
test/maps_test.cc
r789 r877 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). … … 226 226 227 227 checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >(); 228 MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>()); 228 MapToFunctor<ReadMap<A,B> > map = 229 MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>()); 229 230 230 231 check(functorToMap(&func)[A()] == 3, … … 378 379 it != map2.end(); ++it ) 379 380 check(v1[i++] == *it, "Something is wrong with LoggerBoolMap"); 380 381 381 382 typedef ListDigraph Graph; 382 383 DIGRAPH_TYPEDEFS(Graph); … … 387 388 Node n2 = gr.addNode(); 388 389 Node n3 = gr.addNode(); 389 390 390 391 gr.addArc(n3, n0); 391 392 gr.addArc(n3, n2); … … 393 394 gr.addArc(n2, n1); 394 395 gr.addArc(n0, n1); 395 396 396 397 { 397 398 std::vector<Node> v; … … 404 405 std::vector<Node> v(countNodes(gr)); 405 406 dfs(gr).processedMap(loggerBoolMap(v.begin())).run(); 406 407 407 408 check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3, 408 409 "Something is wrong with LoggerBoolMap"); 409 410 } 410 411 } 411 412 412 413 // IdMap, RangeIdMap 413 414 { … … 419 420 checkConcept<ReadMap<Node, int>, RangeIdMap<Graph, Node> >(); 420 421 checkConcept<ReadMap<Arc, int>, RangeIdMap<Graph, Arc> >(); 421 422 422 423 Graph gr; 423 424 IdMap<Graph, Node> nmap(gr); … … 425 426 RangeIdMap<Graph, Node> nrmap(gr); 426 427 RangeIdMap<Graph, Arc> armap(gr); 427 428 428 429 Node n0 = gr.addNode(); 429 430 Node n1 = gr.addNode(); 430 431 Node n2 = gr.addNode(); 431 432 432 433 Arc a0 = gr.addArc(n0, n1); 433 434 Arc a1 = gr.addArc(n0, n2); 434 435 Arc a2 = gr.addArc(n2, n1); 435 436 Arc a3 = gr.addArc(n2, n0); 436 437 437 438 check(nmap[n0] == gr.id(n0) && nmap(gr.id(n0)) == n0, "Wrong IdMap"); 438 439 check(nmap[n1] == gr.id(n1) && nmap(gr.id(n1)) == n1, "Wrong IdMap"); … … 446 447 check(nmap.inverse()[gr.id(n0)] == n0, "Wrong IdMap::InverseMap"); 447 448 check(amap.inverse()[gr.id(a0)] == a0, "Wrong IdMap::InverseMap"); 448 449 449 450 check(nrmap.size() == 3 && armap.size() == 4, 450 451 "Wrong RangeIdMap::size()"); … … 453 454 check(nrmap[n1] == 1 && nrmap(1) == n1, "Wrong RangeIdMap"); 454 455 check(nrmap[n2] == 2 && nrmap(2) == n2, "Wrong RangeIdMap"); 455 456 456 457 check(armap[a0] == 0 && armap(0) == a0, "Wrong RangeIdMap"); 457 458 check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap"); … … 461 462 check(nrmap.inverse()[0] == n0, "Wrong RangeIdMap::InverseMap"); 462 463 check(armap.inverse()[0] == a0, "Wrong RangeIdMap::InverseMap"); 463 464 464 465 gr.erase(n1); 465 466 466 467 if (nrmap[n0] == 1) nrmap.swap(n0, n2); 467 468 nrmap.swap(n2, n0); 468 469 if (armap[a1] == 1) armap.swap(a1, a3); 469 470 armap.swap(a3, a1); 470 471 471 472 check(nrmap.size() == 2 && armap.size() == 2, 472 473 "Wrong RangeIdMap::size()"); … … 474 475 check(nrmap[n0] == 1 && nrmap(1) == n0, "Wrong RangeIdMap"); 475 476 check(nrmap[n2] == 0 && nrmap(0) == n2, "Wrong RangeIdMap"); 476 477 477 478 check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap"); 478 479 check(armap[a3] == 0 && armap(0) == a3, "Wrong RangeIdMap"); … … 481 482 check(armap.inverse()[0] == a3, "Wrong RangeIdMap::InverseMap"); 482 483 } 483 484 484 485 // SourceMap, TargetMap, ForwardMap, BackwardMap, InDegMap, OutDegMap 485 486 { 486 487 typedef ListGraph Graph; 487 488 GRAPH_TYPEDEFS(Graph); 488 489 489 490 checkConcept<ReadMap<Arc, Node>, SourceMap<Graph> >(); 490 491 checkConcept<ReadMap<Arc, Node>, TargetMap<Graph> >(); … … 498 499 Node n1 = gr.addNode(); 499 500 Node n2 = gr.addNode(); 500 501 501 502 gr.addEdge(n0,n1); 502 503 gr.addEdge(n1,n2); … … 505 506 gr.addEdge(n1,n2); 506 507 gr.addEdge(n0,n1); 507 508 508 509 for (EdgeIt e(gr); e != INVALID; ++e) { 509 510 check(forwardMap(gr)[e] == gr.direct(e, true), "Wrong ForwardMap"); 510 511 check(backwardMap(gr)[e] == gr.direct(e, false), "Wrong BackwardMap"); 511 512 } 512 513 513 514 check(mapCompare(gr, 514 515 sourceMap(orienter(gr, constMap<Edge, bool>(true))), … … 520 521 OutDegMap<Digraph> odm(dgr); 521 522 InDegMap<Digraph> idm(dgr); 522 523 523 524 check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 1, "Wrong OutDegMap"); 524 525 check(idm[n0] == 0 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap"); 525 526 526 527 gr.addEdge(n2, n0); 527 528 … … 529 530 check(idm[n0] == 1 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap"); 530 531 } 531 532 532 533 // CrossRefMap 533 534 { … … 541 542 checkConcept<ReadWriteMap<Node, double>, 542 543 CrossRefMap<Graph, Node, double> >(); 543 544 544 545 Graph gr; 545 546 typedef CrossRefMap<Graph, Node, char> CRMap; 546 547 CRMap map(gr); 547 548 548 549 Node n0 = gr.addNode(); 549 550 Node n1 = gr.addNode(); 550 551 Node n2 = gr.addNode(); 551 552 552 553 map.set(n0, 'A'); 553 554 map.set(n1, 'B'); 554 555 map.set(n2, 'C'); 555 556 556 557 check(map[n0] == 'A' && map('A') == n0 && map.inverse()['A'] == n0, 557 558 "Wrong CrossRefMap"); … … 562 563 check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1, 563 564 "Wrong CrossRefMap::count()"); 564 565 565 566 CRMap::ValueIt it = map.beginValue(); 566 567 check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' && 567 568 it == map.endValue(), "Wrong value iterator"); 568 569 569 570 map.set(n2, 'A'); 570 571 … … 604 605 checkConcept<ReadWriteMap<Node, int>, 605 606 CrossRefMap<Graph, Node, int> >(); 606 607 607 608 Graph gr; 608 609 typedef CrossRefMap<Graph, Node, char> CRMap; 609 610 typedef CRMap::ValueIterator ValueIt; 610 611 CRMap map(gr); 611 612 612 613 Node n0 = gr.addNode(); 613 614 Node n1 = gr.addNode(); 614 615 Node n2 = gr.addNode(); 615 616 616 617 map.set(n0, 'A'); 617 618 map.set(n1, 'B'); … … 630 631 it == map.endValue(), "Wrong value iterator"); 631 632 } 632 633 633 634 // Iterable bool map 634 635 { … … 818 819 819 820 } 820 821 821 822 // Graph map utilities: 822 823 // mapMin(), mapMax(), mapMinValue(), mapMaxValue() … … 830 831 Node n2 = g.addNode(); 831 832 Node n3 = g.addNode(); 832 833 833 834 SmartDigraph::NodeMap<int> map1(g); 834 835 SmartDigraph::ArcMap<char> map2(g); 835 836 ConstMap<Node, A> cmap1 = A(); 836 837 ConstMap<Arc, C> cmap2 = C(0); 837 838 838 839 map1[n1] = 10; 839 840 map1[n2] = 5; 840 841 map1[n3] = 12; 841 842 842 843 // mapMin(), mapMax(), mapMinValue(), mapMaxValue() 843 844 check(mapMin(g, map1) == n2, "Wrong mapMin()"); … … 858 859 Arc a3 = g.addArc(n2, n3); 859 860 Arc a4 = g.addArc(n3, n1); 860 861 861 862 map2[a1] = 'b'; 862 863 map2[a2] = 'a'; … … 925 926 check(mapCountIf(g, map2, Less<char>('a')) == 0, 926 927 "Wrong mapCountIf()"); 927 928 928 929 // MapIt, ConstMapIt 929 930 /* … … 935 936 check(*std::max_element(ConstMapIt(map1), ConstMapIt(INVALID)) == 12, 936 937 "Wrong NodeMap<>::MapIt"); 937 938 938 939 int sum = 0; 939 940 std::for_each(MapIt(map1), MapIt(INVALID), Sum<int>(sum)); … … 952 953 SmartDigraph::NodeMap<int> map3(g, 0); 953 954 SmartDigraph::ArcMap<char> map4(g, 'a'); 954 955 955 956 check(!mapCompare(g, map1, map3), "Wrong mapCompare()"); 956 check(!mapCompare(g, map2, map4), "Wrong mapCompare()"); 957 957 check(!mapCompare(g, map2, map4), "Wrong mapCompare()"); 958 958 959 mapCopy(g, map1, map3); 959 960 mapCopy(g, map2, map4); 960 961 961 962 check(mapCompare(g, map1, map3), "Wrong mapCompare() or mapCopy()"); 962 check(mapCompare(g, map2, map4), "Wrong mapCompare() or mapCopy()"); 963 963 check(mapCompare(g, map2, map4), "Wrong mapCompare() or mapCopy()"); 964 964 965 Undirector<SmartDigraph> ug(g); 965 966 Undirector<SmartDigraph>::EdgeMap<char> umap1(ug, 'x'); 966 967 Undirector<SmartDigraph>::ArcMap<double> umap2(ug, 3.14); 967 968 968 969 check(!mapCompare(g, map2, umap1), "Wrong mapCompare() or mapCopy()"); 969 970 check(!mapCompare(g, umap1, map2), "Wrong mapCompare() or mapCopy()"); 970 971 check(!mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()"); 971 972 check(!mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()"); 972 973 973 974 mapCopy(g, map2, umap1); 974 975 … … 977 978 check(mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()"); 978 979 check(mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()"); 979 980 980 981 mapCopy(g, map2, umap1); 981 982 mapCopy(g, umap1, map2); 982 983 mapCopy(ug, map2, umap1); 983 984 mapCopy(ug, umap1, map2); 984 985 985 986 check(!mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()"); 986 987 mapCopy(ug, umap1, umap2); 987 988 check(mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()"); 988 989 989 990 check(!mapCompare(g, map1, constMap<Node>(2)), "Wrong mapCompare()"); 990 991 mapFill(g, map1, 2); … … 995 996 check(mapCompare(g, constMap<Arc>('z'), map2), "Wrong mapCopy()"); 996 997 } 997 998 998 999 return 0; 999 1000 } -
test/matching_test.cc
r870 r877 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 const MaxMatching<Graph>::StatusMap& smap = … … 171 171 mat_test.start(); 172 172 mat_test.run(); 173 173 174 174 const_mat_test.matchingWeight(); 175 175 const_mat_test.matchingSize(); … … 180 180 e = mmap[n]; 181 181 const_mat_test.mate(n); 182 182 183 183 int k = 0; 184 184 const_mat_test.dualValue(); … … 208 208 mat_test.start(); 209 209 mat_test.run(); 210 210 211 211 const_mat_test.matchingWeight(); 212 212 const_mat_test.matching(e); … … 216 216 e = mmap[n]; 217 217 const_mat_test.mate(n); 218 218 219 219 int k = 0; 220 220 const_mat_test.dualValue(); … … 426 426 MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight); 427 427 bool result = mwpm.run(); 428 428 429 429 check(result == perfect, "Perfect matching found"); 430 430 if (perfect) { … … 437 437 mwpm.init(); 438 438 bool result = mwpm.start(); 439 439 440 440 check(result == perfect, "Perfect matching found"); 441 441 if (perfect) { -
test/min_cost_arborescence_test.cc
r625 r877 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). … … 111 111 b = const_mcarb_test.emptyQueue(); 112 112 i = const_mcarb_test.queueSize(); 113 113 114 114 c = const_mcarb_test.arborescenceCost(); 115 115 b = const_mcarb_test.arborescence(e); … … 121 121 b = const_mcarb_test.reached(n); 122 122 b = const_mcarb_test.processed(n); 123 123 124 124 i = const_mcarb_test.dualNum(); 125 125 c = const_mcarb_test.dualValue(); 126 126 i = const_mcarb_test.dualSize(i); 127 127 c = const_mcarb_test.dualValue(i); 128 128 129 129 ignore_unused_variable_warning(am); 130 130 ignore_unused_variable_warning(pm); -
test/min_cost_flow_test.cc
r830 r877 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). … … 53 53 " 11 0 0 0 0 -10 0\n" 54 54 " 12 -20 -27 0 -30 -30 -20\n" 55 "\n" 55 "\n" 56 56 "@arcs\n" 57 57 " cost cap low1 low2 low3\n" … … 103 103 "6 7 30 0 -1000\n" 104 104 "7 5 -120 0 0\n"; 105 105 106 106 char test_neg2_lgf[] = 107 107 "@nodes\n" … … 152 152 void constraints() { 153 153 checkConcept<concepts::Digraph, GR>(); 154 154 155 155 const Constraints& me = *this; 156 156 … … 181 181 typedef concepts::WriteMap<Arc, Value> FlowMap; 182 182 typedef concepts::WriteMap<Node, Cost> PotMap; 183 183 184 184 GR g; 185 185 VAM lower; … … 235 235 typename CM, typename SM, typename FM, typename PM > 236 236 bool checkPotential( const GR& gr, const LM& lower, const UM& upper, 237 const CM& cost, const SM& supply, const FM& flow, 237 const CM& cost, const SM& supply, const FM& flow, 238 238 const PM& pi, SupplyType type ) 239 239 { … … 248 248 (red_cost < 0 && flow[e] == upper[e]); 249 249 } 250 250 251 251 for (NodeIt n(gr); opt && n != INVALID; ++n) { 252 252 typename SM::Value sum = 0; … … 261 261 } 262 262 } 263 263 264 264 return opt; 265 265 } … … 286 286 } 287 287 } 288 288 289 289 for (NodeIt n(gr); n != INVALID; ++n) { 290 290 dual_cost -= red_supply[n] * pi[n]; … … 295 295 dual_cost -= (upper[a] - lower[a]) * std::max(-red_cost, 0); 296 296 } 297 297 298 298 return dual_cost == total; 299 299 } … … 333 333 { 334 334 MCF mcf1(gr), mcf2(neg1_gr), mcf3(neg2_gr); 335 335 336 336 // Basic tests 337 337 mcf1.upperMap(u).costMap(c).supplyMap(s1); … … 436 436 .node("target", w) 437 437 .run(); 438 438 439 439 std::istringstream neg_inp1(test_neg1_lgf); 440 440 DigraphReader<Digraph>(neg1_gr, neg_inp1) … … 444 444 .nodeMap("sup", neg1_s) 445 445 .run(); 446 446 447 447 std::istringstream neg_inp2(test_neg2_lgf); 448 448 DigraphReader<Digraph>(neg2_gr, neg_inp2) … … 450 450 .nodeMap("sup", neg2_s) 451 451 .run(); 452 452 453 453 // Check the interface of NetworkSimplex 454 454 { … … 502 502 503 503 // Test NetworkSimplex 504 { 504 { 505 505 typedef NetworkSimplex<Digraph> MCF; 506 506 runMcfGeqTests<MCF>(MCF::FIRST_ELIGIBLE, "NS-FE", true); … … 515 515 runMcfLeqTests<MCF>(MCF::ALTERING_LIST, "NS-AL"); 516 516 } 517 517 518 518 // Test CapacityScaling 519 519 { -
test/min_mean_cycle_test.cc
r864 r877 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). … … 62 62 "7 7 4 4 4 -1 0 0 0 1\n"; 63 63 64 64 65 65 // Check the interface of an MMC algorithm 66 66 template <typename GR, typename Cost> … … 78 78 MmcAlg mmc(me.g, me.cost); 79 79 const MmcAlg& const_mmc = mmc; 80 80 81 81 typename MmcAlg::Tolerance tol = const_mmc.tolerance(); 82 82 mmc.tolerance(tol); 83 83 84 84 b = mmc.cycle(p).run(); 85 85 b = mmc.findCycleMean(); … … 93 93 94 94 typedef concepts::ReadMap<typename GR::Arc, Cost> CM; 95 95 96 96 GR g; 97 97 CM cost; … … 154 154 checkConcept< MmcClassConcept<GR, float>, 155 155 KarpMmc<GR, concepts::ReadMap<GR::Arc, float> > >(); 156 156 157 157 // HartmannOrlinMmc 158 158 checkConcept< MmcClassConcept<GR, int>, … … 160 160 checkConcept< MmcClassConcept<GR, float>, 161 161 HartmannOrlinMmc<GR, concepts::ReadMap<GR::Arc, float> > >(); 162 162 163 163 // HowardMmc 164 164 checkConcept< MmcClassConcept<GR, int>, … … 177 177 typedef SmartDigraph GR; 178 178 DIGRAPH_TYPEDEFS(GR); 179 179 180 180 GR gr; 181 181 IntArcMap l1(gr), l2(gr), l3(gr), l4(gr); 182 182 IntArcMap c1(gr), c2(gr), c3(gr), c4(gr); 183 183 184 184 std::istringstream input(test_lgf); 185 185 digraphReader(gr, input). -
test/preflow_test.cc
r689 r877 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). … … 95 95 PreflowType preflow_test(g, cap, n, n); 96 96 const PreflowType& const_preflow_test = preflow_test; 97 97 98 98 const PreflowType::Elevator& elev = const_preflow_test.elevator(); 99 99 preflow_test.elevator(const_cast<PreflowType::Elevator&>(elev)); … … 119 119 b = const_preflow_test.minCut(n); 120 120 const_preflow_test.minCutMap(cut); 121 121 122 122 ignore_unused_variable_warning(fm); 123 123 } -
test/suurballe_test.cc
r858 r877 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). … … 82 82 typedef Digraph::Arc Arc; 83 83 typedef concepts::ReadMap<Arc, VType> LengthMap; 84 84 85 85 typedef Suurballe<Digraph, LengthMap> ST; 86 86 typedef Suurballe<Digraph, LengthMap> … … 115 115 k = suurb_test.findFlow(n, k); 116 116 suurb_test.findPaths(); 117 117 118 118 int f; 119 119 VType c; … … 127 127 k = const_suurb_test.pathNum(); 128 128 Path<Digraph> p = const_suurb_test.path(k); 129 129 130 130 ignore_unused_variable_warning(fm); 131 131 ignore_unused_variable_warning(pm); … … 209 209 { 210 210 Suurballe<ListDigraph> suurballe(digraph, length); 211 211 212 212 // Find 2 paths 213 213 check(suurballe.run(s, t) == 2, "Wrong number of paths"); … … 220 220 for (int i = 0; i < suurballe.pathNum(); ++i) 221 221 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 222 222 223 223 // Find 3 paths 224 224 check(suurballe.run(s, t, 3) == 3, "Wrong number of paths"); … … 231 231 for (int i = 0; i < suurballe.pathNum(); ++i) 232 232 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 233 233 234 234 // Find 5 paths (only 3 can be found) 235 235 check(suurballe.run(s, t, 5) == 3, "Wrong number of paths"); … … 243 243 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); 244 244 } 245 245 246 246 // Check fullInit() + start() 247 247 { 248 248 Suurballe<ListDigraph> suurballe(digraph, length); 249 249 suurballe.fullInit(s); 250 250 251 251 // Find 2 paths 252 252 check(suurballe.start(t) == 2, "Wrong number of paths"); -
test/test_tools.h
r763 r877 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). … … 46 46 } else { } \ 47 47 } \ 48 48 49 49 50 50 #endif
Note: See TracChangeset
for help on using the changeset viewer.