Changeset 775:e46a1f0623a0 in lemon-0.x for src/work
- Timestamp:
- 08/31/04 13:26:59 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1068
- Location:
- src/work/marci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/augmenting_flow.h
r762 r775 1021 1021 case AFTER_AUGMENTING: 1022 1022 // std::cout << "AFTER_AUGMENTING" << std::endl; 1023 for(g->first(v); g->valid(v); g->next(v)) {1023 for(g->first(v); v!=INVALID; ++v) { 1024 1024 if (level[v]) { 1025 1025 M.set(v, true); … … 1031 1031 case AFTER_FAST_AUGMENTING: 1032 1032 // std::cout << "AFTER_FAST_AUGMENTING" << std::endl; 1033 for(g->first(v); g->valid(v); g->next(v)) {1033 for(g->first(v); v!=INVALID; ++v) { 1034 1034 if (level[v]==number_of_augmentations) { 1035 1035 M.set(v, true); … … 1054 1054 1055 1055 OutEdgeIt e; 1056 for(g->first(e,w) ; g->valid(e); g->next(e)) {1056 for(g->first(e,w) ; e!=INVALID; ++e) { 1057 1057 Node v=g->head(e); 1058 1058 if (!M[v] && (*flow)[e] < (*capacity)[e] ) { … … 1063 1063 1064 1064 InEdgeIt f; 1065 for(g->first(f,w) ; g->valid(f); g->next(f)) {1065 for(g->first(f,w) ; f!=INVALID; ++f) { 1066 1066 Node v=g->tail(f); 1067 1067 if (!M[v] && (*flow)[f] > 0 ) { … … 1134 1134 while ( !bfs.finished() ) { 1135 1135 ResGWOutEdgeIt e=bfs; 1136 if ( res_graph.valid(e)&& bfs.isBNodeNewlyReached()) {1136 if (e!=INVALID && bfs.isBNodeNewlyReached()) { 1137 1137 Node v=res_graph.tail(e); 1138 1138 Node w=res_graph.head(e); 1139 1139 pred.set(w, e); 1140 if ( res_graph.valid(pred[v])) {1140 if (pred[v]!=INVALID) { 1141 1141 free.set(w, std::min(free[v], res_graph.resCap(e))); 1142 1142 } else { … … 1152 1152 Node n=t; 1153 1153 Num augment_value=free[t]; 1154 while ( res_graph.valid(pred[n])) {1154 while (pred[n]!=INVALID) { 1155 1155 ResGWEdge e=pred[n]; 1156 1156 res_graph.augment(e, augment_value); … … 1191 1191 while ( !bfs.finished() ) { 1192 1192 ResGWOutEdgeIt e=bfs; 1193 if ( res_graph.valid(e)&& bfs.isBNodeNewlyReached()) {1193 if (e!=INVALID && bfs.isBNodeNewlyReached()) { 1194 1194 Node v=res_graph.tail(e); 1195 1195 Node w=res_graph.head(e); 1196 1196 pred.set(w, e); 1197 if ( res_graph.valid(pred[v])) {1197 if (pred[v]!=INVALID) { 1198 1198 free.set(w, std::min(free[v], res_graph.resCap(e))); 1199 1199 } else { … … 1209 1209 Node n=t; 1210 1210 Num augment_value=free[t]; 1211 while ( res_graph.valid(pred[n])) {1211 while (pred[n]!=INVALID) { 1212 1212 ResGWEdge e=pred[n]; 1213 1213 res_graph.augment(e, augment_value); … … 1245 1245 { 1246 1246 typename ResGW::NodeIt n; 1247 for(res_graph.first(n); res_graph.valid(n); res_graph.next(n)) {1247 for(res_graph.first(n); n!=INVALID; ++n) { 1248 1248 res_graph_to_F.set(n, F.addNode()); 1249 1249 } … … 1257 1257 while ( !bfs.finished() ) { 1258 1258 ResGWOutEdgeIt e=bfs; 1259 if ( res_graph.valid(e)) {1259 if (e!=INVALID) { 1260 1260 if (bfs.isBNodeNewlyReached()) { 1261 1261 dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1); … … 1300 1300 typename MG::Node w=F.bNode(dfs); 1301 1301 pred.set(w, dfs); 1302 if ( F.valid(pred[v])) {1302 if (pred[v]!=INVALID) { 1303 1303 free.set(w, std::min(free[v], residual_capacity[dfs])); 1304 1304 } else { … … 1320 1320 typename MG::Node n=tF; 1321 1321 Num augment_value=free[tF]; 1322 while ( F.valid(pred[n])) {1322 while (pred[n]!=INVALID) { 1323 1323 typename MG::Edge e=pred[n]; 1324 1324 res_graph.augment(original_edge[e], augment_value); … … 1338 1338 1339 1339 1340 1341 1342 1340 template <typename Graph, typename Num, typename CapMap, typename FlowMap> 1343 1341 bool AugmentingFlow<Graph, Num, CapMap, FlowMap>::augmentOnBlockingFlow2() … … 1355 1353 while ( !bfs.finished() ) { 1356 1354 ResGWOutEdgeIt e=bfs; 1357 if ( res_graph.valid(e)&& bfs.isBNodeNewlyReached()) {1355 if (e!=INVALID && bfs.isBNodeNewlyReached()) { 1358 1356 dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1); 1359 1357 } … … 1372 1370 first_out_edges(filter_res_graph); 1373 1371 typename FilterResGW::NodeIt v; 1374 for(filter_res_graph.first(v); filter_res_graph.valid(v); 1375 filter_res_graph.next(v)) 1372 for(filter_res_graph.first(v); v!=INVALID; ++v) 1376 1373 { 1377 1374 typename FilterResGW::OutEdgeIt e; … … 1419 1416 1420 1417 pred.set(w, /*typename ErasingResGW::OutEdgeIt*/(dfs)); 1421 if ( erasing_res_graph.valid(pred[v])) {1418 if (pred[v]!=INVALID) { 1422 1419 free1.set 1423 1420 (w, std::min(free1[v], res_graph.resCap -
src/work/marci/makefile
r773 r775 5 5 6 6 LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo 7 BINARIES = graph_wrapper_time max_flow_demo iterator_bfs_demo macro_test lg_vs_sg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1 proba7 7 BINARIES = graph_wrapper_time max_flow_demo iterator_bfs_demo macro_test lg_vs_sg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1 proba7 proba8 8 8 #BINARIES = preflow_bug 9 9 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda -
src/work/marci/max_flow_demo.cc
r762 r775 17 17 18 18 // Use a DIMACS max flow file as stdin. 19 // read_dimacs_demo < dimacs_max_flow_file 20 21 22 // struct Ize { 23 // }; 24 25 // struct Mize { 26 // Ize bumm; 27 // }; 28 29 // template <typename B> 30 // class Huha { 31 // public: 32 // int u; 33 // B brr; 34 // }; 35 19 // max_flow_demo < dimacs_max_flow_file 36 20 37 21 int main(int, char **) { … … 44 28 typedef Graph::Node Node; 45 29 typedef Graph::EdgeIt EdgeIt; 46 47 48 // Mize mize[10];49 // Mize bize[0];50 // Mize zize;51 // typedef Mize Tize[0];52 53 // std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;54 // std::cout << sizeof(bize) << std::endl;55 56 57 // Huha<Tize> k;58 // std::cout << sizeof(k) << std::endl;59 60 61 // struct Bumm {62 // //int a;63 // bool b;64 // };65 66 // std::cout << sizeof(Bumm) << std::endl;67 68 30 69 31 Graph g; … … 142 104 143 105 // { 144 // std::cout << " faster physicalblocking flow augmentation ..." << std::endl;106 // std::cout << "on-the-fly blocking flow augmentation ..." << std::endl; 145 107 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 146 108 // ts.reset(); 147 109 // int i=0; 148 // while ( max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }110 // while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; } 149 111 // std::cout << "elapsed time: " << ts << std::endl; 150 112 // std::cout << "number of augmentation phases: " << i << std::endl; 151 // std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; 113 // std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl; 114 115 // FOR_EACH_LOC(Graph::EdgeIt, e, g) { 116 // if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e]) 117 // std::cout << "Slackness does not hold!" << std::endl; 118 // if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0) 119 // std::cout << "Slackness does not hold!" << std::endl; 120 // } 152 121 // } 153 154 {155 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;156 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);157 ts.reset();158 int i=0;159 while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }160 std::cout << "elapsed time: " << ts << std::endl;161 std::cout << "number of augmentation phases: " << i << std::endl;162 std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;163 164 FOR_EACH_LOC(Graph::EdgeIt, e, g) {165 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])166 std::cout << "Slackness does not hold!" << std::endl;167 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)168 std::cout << "Slackness does not hold!" << std::endl;169 }170 }171 122 172 123 {
Note: See TracChangeset
for help on using the changeset viewer.