# Changeset 2180:d5544c9409e4 in lemon-0.x

Ignore:
Timestamp:
08/14/06 18:08:28 (13 years ago)
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2897
Message:

Omit warning
Using check instead of the LEMON_ASSERT
Using fixed graph

File:
1 edited

Unmodified
Added
Removed
• ## test/arborescence_test.cc

 r2025 #include #include "test_tools.h" using namespace lemon; using namespace std; int main(int argc, const char *argv[]) { const int n = 10; const int e = 22; int sourceNode = 0; int sources[e] = { 1, 0, 2, 4, 4, 3, 9, 8, 9, 8, 4, 2, 0, 6, 4, 1, 7, 2, 8, 6, 1, 0 }; int targets[e] = { 8, 3, 1, 1, 4, 9, 8, 1, 8, 0, 3, 2, 1, 3, 1, 1, 2, 6, 3, 9, 1, 3 }; double costs[e] = { 107.444, 70.3069, 46.0496, 28.3962, 91.4325, 76.9443, 61.986, 39.3754, 74.9575, 39.3153, 45.7094, 34.6184, 100.156, 95.726, 22.3429, 31.587, 51.6972, 29.6773, 115.038, 32.4137, 60.0038, 40.1237 }; int main() { srand(time(0)); typedef SmartGraph Graph; typedef Graph::EdgeMap CostMap; const int n = argc > 1 ? atoi(argv[1]) : 100; const int e = argc > 2 ? atoi(argv[2]) : (int)(n * log(n)); Graph graph; for (int i = 0; i < e; ++i) { int s = (int)(n * (double)rand() / (RAND_MAX + 1.0)); int t = (int)(n * (double)rand() / (RAND_MAX + 1.0)); double c = rand() / (1.0 + RAND_MAX) * 100.0 + 20.0; Edge edge = graph.addEdge(nodes[s], nodes[t]); cost[edge] = c; Edge edge = graph.addEdge(nodes[sources[i]], nodes[targets[i]]); cost[edge] = costs[i]; } Node source = nodes[(int)(n * (double)rand() / (RAND_MAX + 1.0))]; Node source = nodes[sourceNode]; MinCostArborescence mca(graph, cost); } if (mca.arborescence(it)) { LEMON_ASSERT(!tolerance.less(sum, cost[it]), "INVALID DUAL"); check(!tolerance.less(sum, cost[it]), "INVALID DUAL"); } LEMON_ASSERT(!tolerance.less(cost[it], sum), "INVALID DUAL"); check(!tolerance.less(cost[it], sum), "INVALID DUAL"); } } LEMON_ASSERT(!tolerance.different(mca.dualValue(), mca.arborescenceValue()), check(!tolerance.different(mca.dualValue(), mca.arborescenceValue()), "INVALID DUAL"); LEMON_ASSERT(mca.reached(source), "INVALID ARBORESCENCE"); check(mca.reached(source), "INVALID ARBORESCENCE"); for (EdgeIt it(graph); it != INVALID; ++it) { LEMON_ASSERT(!mca.reached(graph.source(it)) || check(!mca.reached(graph.source(it)) || mca.reached(graph.target(it)), "INVALID ARBORESCENCE"); } } } LEMON_ASSERT((it == source ? cnt == 0 : cnt == 1), "INVALID ARBORESCENCE"); check((it == source ? cnt == 0 : cnt == 1), "INVALID ARBORESCENCE"); }
Note: See TracChangeset for help on using the changeset viewer.