Changeset 672:029a48052c67 in lemon for test/min_cost_arborescence_test.cc
 Timestamp:
 04/26/09 16:44:53 (12 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/min_cost_arborescence_test.cc
r522 r672 25 25 #include <lemon/min_cost_arborescence.h> 26 26 #include <lemon/lgf_reader.h> 27 #include <lemon/concepts/digraph.h> 27 28 28 29 #include "test_tools.h" … … 71 72 "source 0\n"; 72 73 74 75 void checkMinCostArborescenceCompile() 76 { 77 typedef double VType; 78 typedef concepts::Digraph Digraph; 79 typedef concepts::ReadMap<Digraph::Arc, VType> CostMap; 80 typedef Digraph::Node Node; 81 typedef Digraph::Arc Arc; 82 typedef concepts::WriteMap<Digraph::Arc, bool> ArbMap; 83 typedef concepts::ReadWriteMap<Digraph::Node, Digraph::Arc> PredMap; 84 85 typedef MinCostArborescence<Digraph, CostMap>:: 86 SetArborescenceMap<ArbMap>:: 87 SetPredMap<PredMap>::Create MinCostArbType; 88 89 Digraph g; 90 Node s, n; 91 Arc e; 92 VType c; 93 bool b; 94 int i; 95 CostMap cost; 96 ArbMap arb; 97 PredMap pred; 98 99 MinCostArbType mcarb_test(g, cost); 100 const MinCostArbType& const_mcarb_test = mcarb_test; 101 102 mcarb_test 103 .arborescenceMap(arb) 104 .predMap(pred) 105 .run(s); 106 107 mcarb_test.init(); 108 mcarb_test.addSource(s); 109 mcarb_test.start(); 110 n = mcarb_test.processNextNode(); 111 b = const_mcarb_test.emptyQueue(); 112 i = const_mcarb_test.queueSize(); 113 114 c = const_mcarb_test.arborescenceCost(); 115 b = const_mcarb_test.arborescence(e); 116 e = const_mcarb_test.pred(n); 117 const MinCostArbType::ArborescenceMap &am = 118 const_mcarb_test.arborescenceMap(); 119 const MinCostArbType::PredMap &pm = 120 const_mcarb_test.predMap(); 121 b = const_mcarb_test.reached(n); 122 b = const_mcarb_test.processed(n); 123 124 i = const_mcarb_test.dualNum(); 125 c = const_mcarb_test.dualValue(); 126 i = const_mcarb_test.dualSize(i); 127 c = const_mcarb_test.dualValue(i); 128 129 ignore_unused_variable_warning(am); 130 ignore_unused_variable_warning(pm); 131 } 132 73 133 int main() { 74 134 typedef SmartDigraph Digraph; … … 111 171 } 112 172 if (mca.arborescence(it)) { 113 check(sum == cost[it], "I NVALID DUAL");173 check(sum == cost[it], "Invalid dual solution"); 114 174 } 115 check(sum <= cost[it], "I NVALID DUAL");175 check(sum <= cost[it], "Invalid dual solution"); 116 176 } 117 177 } 118 178 119 179 120 check(mca.dualValue() == mca.arborescence Value(), "INVALID DUAL");121 122 check(mca.reached(source), "I NVALID ARBORESCENCE");180 check(mca.dualValue() == mca.arborescenceCost(), "Invalid dual solution"); 181 182 check(mca.reached(source), "Invalid arborescence"); 123 183 for (ArcIt a(digraph); a != INVALID; ++a) { 124 184 check(!mca.reached(digraph.source(a))  125 mca.reached(digraph.target(a)), "I NVALID ARBORESCENCE");185 mca.reached(digraph.target(a)), "Invalid arborescence"); 126 186 } 127 187 … … 131 191 for (InArcIt a(digraph, n); a != INVALID; ++a) { 132 192 if (mca.arborescence(a)) { 133 check(mca.pred(n) == a, "I NVALID ARBORESCENCE");193 check(mca.pred(n) == a, "Invalid arborescence"); 134 194 ++cnt; 135 195 } 136 196 } 137 check((n == source ? cnt == 0 : cnt == 1), "I NVALID ARBORESCENCE");197 check((n == source ? cnt == 0 : cnt == 1), "Invalid arborescence"); 138 198 } 139 199 140 200 Digraph::ArcMap<bool> arborescence(digraph); 141 check(mca.arborescence Value() ==201 check(mca.arborescenceCost() == 142 202 minCostArborescence(digraph, cost, source, arborescence), 143 "W RONG FUNCTION");203 "Wrong result of the function interface"); 144 204 145 205 return 0;
Note: See TracChangeset
for help on using the changeset viewer.