Changeset 2386:81b47fc5c444 in lemon-0.x for test
- Timestamp:
- 03/02/07 19:04:28 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3217
- Location:
- test
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
test/all_pairs_shortest_path_test.cc
r2335 r2386 49 49 50 50 const int n = argc > 1 ? atoi(argv[1]) : 20; 51 const int e = argc > 2 ? atoi(argv[2]) : (int)(n * log((double)n));51 const int e = argc > 2 ? atoi(argv[2]) : int(n * log(double(n))); 52 52 const int m = argc > 3 ? atoi(argv[3]) : 100; 53 53 -
test/arborescence_test.cc
r2242 r2386 20 20 using namespace std; 21 21 22 const int n= 10;23 const int e= 22;22 const int NODES = 10; 23 const int EDGES = 22; 24 24 25 25 int sourceNode = 0; 26 26 27 int sources[ e] = {27 int sources[EDGES] = { 28 28 1, 0, 2, 4, 4, 3, 9, 8, 9, 8, 29 29 4, 2, 0, 6, 4, 1, 7, 2, 8, 6, … … 31 31 }; 32 32 33 int targets[ e] = {33 int targets[EDGES] = { 34 34 8, 3, 1, 1, 4, 9, 8, 1, 8, 0, 35 35 3, 2, 1, 3, 1, 1, 2, 6, 3, 9, … … 37 37 }; 38 38 39 double costs[ e] = {39 double costs[EDGES] = { 40 40 107.444, 70.3069, 46.0496, 28.3962, 91.4325, 41 41 76.9443, 61.986, 39.3754, 74.9575, 39.3153, … … 57 57 vector<Node> nodes; 58 58 59 for (int i = 0; i < n; ++i) {59 for (int i = 0; i < NODES; ++i) { 60 60 nodes.push_back(graph.addNode()); 61 61 } 62 62 63 for (int i = 0; i < e; ++i) {63 for (int i = 0; i < EDGES; ++i) { 64 64 Edge edge = graph.addEdge(nodes[sources[i]], nodes[targets[i]]); 65 65 cost[edge] = costs[i]; … … 86 86 if (mca.reached(graph.source(it))) { 87 87 double sum = 0.0; 88 for (int i = 0; i < (int)dualSolution.size(); ++i) {88 for (int i = 0; i < int(dualSolution.size()); ++i) { 89 89 if (dualSolution[i].second.find(graph.target(it)) 90 90 != dualSolution[i].second.end() && -
test/bipartite_matching_test.cc
r2137 r2386 20 20 BPUGRAPH_TYPEDEFS(Graph); 21 21 22 const int n= 10;23 const int m= 10;24 const int e= 52;25 const int c= 100;26 27 const int sa[ e] = { 6, 5, 6, 4, 1, 0, 9, 5, 2, 4, 4, 3, 5,22 const int N = 10; 23 const int M = 10; 24 const int E = 52; 25 const int C = 100; 26 27 const int sa[E] = { 6, 5, 6, 4, 1, 0, 9, 5, 2, 4, 4, 3, 5, 28 28 2, 3, 8, 3, 4, 9, 6, 9, 4, 3, 1, 5, 8, 29 29 4, 8, 9, 2, 2, 3, 0, 5, 2, 3, 6, 3, 8, 30 30 8, 4, 0, 9, 9, 6, 2, 1, 2, 7, 1, 9, 4}; 31 31 32 const int ta[ e] = { 2, 7, 4, 8, 6, 3, 4, 1, 7, 7, 0, 1, 6,32 const int ta[E] = { 2, 7, 4, 8, 6, 3, 4, 1, 7, 7, 0, 1, 6, 33 33 3, 2, 6, 8, 3, 5, 6, 3, 1, 8, 7, 2, 0, 34 34 6, 9, 6, 7, 8, 3, 3, 4, 5, 8, 6, 4, 1, 35 35 4, 3, 3, 8, 7, 7, 3, 7, 7, 3, 5, 1, 6}; 36 36 37 const int wa[ e] = { 3, 99, 85, 16, 79, 52, 83, 99, 62, 6, 42, 6, 95,37 const int wa[E] = { 3, 99, 85, 16, 79, 52, 83, 99, 62, 6, 42, 6, 95, 38 38 13, 34, 9, 5, 38, 39, 75, 99, 12, 73, 35, 93, 43, 39 39 54, 91, 45, 26, 77, 47, 11, 22, 50, 74, 37, 64, 91, … … 53 53 int min_cost_matching; 54 54 55 for (int i = 0; i < n; ++i) {55 for (int i = 0; i < N; ++i) { 56 56 Node node = graph.addANode(); 57 57 aNodes.push_back(node); 58 58 } 59 for (int i = 0; i < m; ++i) {59 for (int i = 0; i < M; ++i) { 60 60 Node node = graph.addBNode(); 61 61 bNodes.push_back(node); 62 62 } 63 for (int i = 0; i < e; ++i) {63 for (int i = 0; i < E; ++i) { 64 64 Node aNode = aNodes[sa[i]]; 65 65 Node bNode = bNodes[ta[i]]; … … 289 289 290 290 Graph::UEdgeMap<int> cost(graph); 291 cost = subMap(constMap<UEdge>( c), weight);291 cost = subMap(constMap<UEdge>(C), weight); 292 292 { 293 293 … … 304 304 min_cost_matching = bpmatch.matchingCost(); 305 305 check(max_cardinality == bpmatch.matchingSize(), "WRONG SIZE"); 306 check(max_cardinality * c- max_cardinality_max_weight306 check(max_cardinality * C - max_cardinality_max_weight 307 307 == bpmatch.matchingCost(), "WRONG SIZE"); 308 308 … … 327 327 min_cost_matching = bpmatch.matchingCost(); 328 328 check(max_cardinality == bpmatch.matchingSize(), "WRONG SIZE"); 329 check(max_cardinality * c- max_cardinality_max_weight329 check(max_cardinality * C - max_cardinality_max_weight 330 330 == bpmatch.matchingCost(), "WRONG SIZE"); 331 331 -
test/lp_test.cc
r2369 r2386 262 262 263 263 if (stat == LpSolverBase::OPTIMAL) { 264 std::ostringstream buf;265 buf << "Wrong optimal value: the right optimum is " << exp_opt;266 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, buf.str());264 std::ostringstream sbuf; 265 sbuf << "Wrong optimal value: the right optimum is " << exp_opt; 266 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, sbuf.str()); 267 267 //+ecvt(exp_opt,2) 268 268 } -
test/map_test.h
r1956 r2386 46 46 typedef typename Graph::template NodeMap<int> IntNodeMap; 47 47 IntNodeMap map(graph, 42); 48 for (int i = 0; i < (int)nodes.size(); ++i) {48 for (int i = 0; i < int(nodes.size()); ++i) { 49 49 check(map[nodes[i]] == 42, "Wrong map constructor."); 50 50 } … … 54 54 } 55 55 map = constMap<Node>(12); 56 for (int i = 0; i < (int)nodes.size(); ++i) {56 for (int i = 0; i < int(nodes.size()); ++i) { 57 57 check(map[nodes[i]] == 12, "Wrong map constructor."); 58 58 } … … 84 84 IntEdgeMap map(graph, 42); 85 85 86 for (int i = 0; i < (int)edges.size(); ++i) {86 for (int i = 0; i < int(edges.size()); ++i) { 87 87 check(map[edges[i]] == 42, "Wrong map constructor."); 88 88 } … … 95 95 } 96 96 map = constMap<Edge>(12); 97 for (int i = 0; i < (int)edges.size(); ++i) {97 for (int i = 0; i < int(edges.size()); ++i) { 98 98 check(map[edges[i]] == 12, "Wrong map constructor."); 99 99 } -
test/max_matching_test.cc
r2116 r2386 75 75 if ( mate[v]!=INVALID ) ++s; 76 76 } 77 int size= (int)s/2; //size will be used as the size of a maxmatching77 int size=int(s/2); //size will be used as the size of a maxmatching 78 78 79 79 for(NodeIt v(g); v!=INVALID; ++v) { … … 93 93 if ( mate[v]!=INVALID ) ++s; 94 94 } 95 check ( (int)s/2== size, "The size does not equal!" );95 check ( int(s/2) == size, "The size does not equal!" ); 96 96 97 97 Graph::NodeMap<MaxMatching<Graph>::pos_enum> pos1(g); … … 104 104 if ( mate[v]!=INVALID ) ++s; 105 105 } 106 check ( (int)s/2== size, "The size does not equal!" );106 check ( int(s/2) == size, "The size does not equal!" ); 107 107 108 108 Graph::NodeMap<MaxMatching<Graph>::pos_enum> pos2(g); … … 116 116 if ( mate[v]!=INVALID ) ++s; 117 117 } 118 check ( (int)s/2== size, "The size does not equal!" );118 check ( int(s/2) == size, "The size does not equal!" ); 119 119 120 120 Graph::NodeMap<MaxMatching<Graph>::pos_enum> pos(g); … … 177 177 if ( pos[v]==max_matching.A ) ++barrier; 178 178 } 179 int expected_size= (int)( countNodes(g)-num_comp+barrier)/2;179 int expected_size=int( countNodes(g)-num_comp+barrier)/2; 180 180 check ( size==expected_size, "The size of the matching is wrong." ); 181 181 -
test/mip_test.cc
r2369 r2386 31 31 32 32 if (stat == MipSolverBase::OPTIMAL) { 33 std::ostringstream buf;33 std::ostringstream sbuf; 34 34 buf << "Wrong optimal value: the right optimum is " << exp_opt; 35 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, buf.str());35 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, sbuf.str()); 36 36 //+ecvt(exp_opt,2) 37 37 } -
test/radix_sort_test.cc
r2242 r2386 33 33 using namespace lemon; 34 34 35 typedef unsigned char uchar; 36 35 37 void checkRadixSort() { 36 38 { … … 49 51 vector<unsigned char> data1(n), data2(n); 50 52 for (int i = 0; i < n; ++i) { 51 data1[i] = data2[i] = rnd[ (unsigned char)200];53 data1[i] = data2[i] = rnd[uchar(200)]; 52 54 } 53 55 radixSort(data1.begin(), data1.end()); … … 76 78 vector<unsigned char> data1(n), data2(n); 77 79 for (int i = 0; i < n; ++i) { 78 data1[i] = data2[i] = rnd[ (unsigned char)200];80 data1[i] = data2[i] = rnd[uchar(200)]; 79 81 } 80 82 counterSort(data1.begin(), data1.end()); … … 97 99 98 100 const int n = 100; 99 const int e = (int)(n * log((double)n));101 const int e = int(n * log(double(n))); 100 102 101 103 Graph graph; … … 118 120 Graph::EdgeMap<bool> was(graph, false); 119 121 120 for (int i = 0; i < (int)edges.size(); ++i) {122 for (int i = 0; i < int(edges.size()); ++i) { 121 123 check(!was[edges[i]], "Test failed"); 122 124 was[edges[i]] = true; 123 125 } 124 126 125 for (int i = 1; i < (int)edges.size(); ++i) {127 for (int i = 1; i < int(edges.size()); ++i) { 126 128 check(graph.id(graph.source(edges[i - 1])) <= 127 129 graph.id(graph.source(edges[i])), "Test failed"); … … 136 138 137 139 const int n = 100; 138 const int e = (int)(n * log((double)n));140 const int e = int(n * log(double(n))); 139 141 140 142 Graph graph; … … 161 163 Graph::EdgeMap<bool> was(graph, false); 162 164 163 for (int i = 0; i < (int)edges.size(); ++i) {165 for (int i = 0; i < int(edges.size()); ++i) { 164 166 check(!was[edges[i]], "Test failed"); 165 167 was[edges[i]] = true; 166 168 } 167 169 168 for (int i = 1; i < (int)edges.size(); ++i) {170 for (int i = 1; i < int(edges.size()); ++i) { 169 171 check(graph.id(graph.target(edges[i - 1])) < 170 172 graph.id(graph.target(edges[i])) ||
Note: See TracChangeset
for help on using the changeset viewer.