Changeset 269:07af3069c0b8 in lemon-0.x for src/work/marci/graph_wrapper.h
- Timestamp:
- 03/31/04 17:50:21 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@375
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/graph_wrapper.h
r266 r269 1000 1000 OutEdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() { 1001 1001 resG.gw.first(out, v); 1002 while( resG.gw.valid(out) && !(resG. free(out)>0) ) { resG.gw.next(out); }1002 while( resG.gw.valid(out) && !(resG.resCap(out)>0) ) { resG.gw.next(out); } 1003 1003 if (!resG.gw.valid(out)) { 1004 1004 out_or_in=0; 1005 1005 resG.gw.first(in, v); 1006 while( resG.gw.valid(in) && !(resG. free(in)>0) ) { resG.gw.next(in); }1006 while( resG.gw.valid(in) && !(resG.resCap(in)>0) ) { resG.gw.next(in); } 1007 1007 } 1008 1008 } … … 1012 1012 // Node v=/*resG->*/G->aNode(out); 1013 1013 // ++out; 1014 // while( out.valid() && !(Edge:: free()>0) ) { ++out; }1014 // while( out.valid() && !(Edge::resCap()>0) ) { ++out; } 1015 1015 // if (!out.valid()) { 1016 1016 // out_or_in=0; 1017 1017 // G->first(in, v); 1018 // while( in.valid() && !(Edge:: free()>0) ) { ++in; }1018 // while( in.valid() && !(Edge::resCap()>0) ) { ++in; } 1019 1019 // } 1020 1020 // } else { 1021 1021 // ++in; 1022 // while( in.valid() && !(Edge:: free()>0) ) { ++in; }1022 // while( in.valid() && !(Edge::resCap()>0) ) { ++in; } 1023 1023 // } 1024 1024 // return *this; … … 1038 1038 EdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG) : Edge() { 1039 1039 resG.gw.first(v); 1040 if (resG.gw.valid(v)) resG.gw.first(out, v); else out= /*OldOutEdgeIt*/(INVALID);1041 while (resG.gw.valid(out) && !(resG. free(out)>0) ) { resG.gw.next(out); }1040 if (resG.gw.valid(v)) resG.gw.first(out, v); else out=INVALID; 1041 while (resG.gw.valid(out) && !(resG.resCap(out)>0) ) { resG.gw.next(out); } 1042 1042 while (resG.gw.valid(v) && !resG.gw.valid(out)) { 1043 1043 resG.gw.next(v); 1044 1044 if (resG.gw.valid(v)) resG.gw.first(out, v); 1045 while (resG.gw.valid(out) && !(resG. free(out)>0) ) { resG.gw.next(out); }1045 while (resG.gw.valid(out) && !(resG.resCap(out)>0) ) { resG.gw.next(out); } 1046 1046 } 1047 1047 if (!resG.gw.valid(out)) { 1048 1048 out_or_in=0; 1049 1049 resG.gw.first(v); 1050 if (resG.gw.valid(v)) resG.gw.first(in, v); else in= /*OldInEdgeIt*/(INVALID);1051 while (resG.gw.valid(in) && !(resG. free(in)>0) ) { resG.gw.next(in); }1050 if (resG.gw.valid(v)) resG.gw.first(in, v); else in=INVALID; 1051 while (resG.gw.valid(in) && !(resG.resCap(in)>0) ) { resG.gw.next(in); } 1052 1052 while (resG.gw.valid(v) && !resG.gw.valid(in)) { 1053 1053 resG.gw.next(v); 1054 1054 if (resG.gw.valid(v)) resG.gw.first(in, v); 1055 while (resG.gw.valid(in) && !(resG. free(in)>0) ) { resG.gw.next(in); }1055 while (resG.gw.valid(in) && !(resG.resCap(in)>0) ) { resG.gw.next(in); } 1056 1056 } 1057 1057 } … … 1060 1060 // if (out_or_in) { 1061 1061 // ++out; 1062 // while (out.valid() && !(Edge:: free()>0) ) { ++out; }1062 // while (out.valid() && !(Edge::resCap()>0) ) { ++out; } 1063 1063 // while (v.valid() && !out.valid()) { 1064 1064 // ++v; 1065 1065 // if (v.valid()) G->first(out, v); 1066 // while (out.valid() && !(Edge:: free()>0) ) { ++out; }1066 // while (out.valid() && !(Edge::resCap()>0) ) { ++out; } 1067 1067 // } 1068 1068 // if (!out.valid()) { … … 1070 1070 // G->first(v); 1071 1071 // if (v.valid()) G->first(in, v); else in=OldInEdgeIt(); 1072 // while (in.valid() && !(Edge:: free()>0) ) { ++in; }1072 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; } 1073 1073 // while (v.valid() && !in.valid()) { 1074 1074 // ++v; 1075 1075 // if (v.valid()) G->first(in, v); 1076 // while (in.valid() && !(Edge:: free()>0) ) { ++in; }1076 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; } 1077 1077 // } 1078 1078 // } 1079 1079 // } else { 1080 1080 // ++in; 1081 // while (in.valid() && !(Edge:: free()>0) ) { ++in; }1081 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; } 1082 1082 // while (v.valid() && !in.valid()) { 1083 1083 // ++v; 1084 1084 // if (v.valid()) G->first(in, v); 1085 // while (in.valid() && !(Edge:: free()>0) ) { ++in; }1085 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; } 1086 1086 // } 1087 1087 // } … … 1106 1106 Node v=gw.aNode(e.out); 1107 1107 gw.next(e.out); 1108 while( gw.valid(e.out) && !( free(e.out)>0) ) { gw.next(e.out); }1108 while( gw.valid(e.out) && !(resCap(e.out)>0) ) { gw.next(e.out); } 1109 1109 if (!gw.valid(e.out)) { 1110 1110 e.out_or_in=0; 1111 1111 gw.first(e.in, v); 1112 while( gw.valid(e.in) && !( free(e.in)>0) ) { gw.next(e.in); }1112 while( gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); } 1113 1113 } 1114 1114 } else { 1115 1115 gw.next(e.in); 1116 while( gw.valid(e.in) && !( free(e.in)>0) ) { gw.next(e.in); }1116 while( gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); } 1117 1117 } 1118 1118 return e; … … 1122 1122 if (e.out_or_in) { 1123 1123 gw.next(e.out); 1124 while (gw.valid(e.out) && !( free(e.out)>0) ) { gw.next(e.out); }1124 while (gw.valid(e.out) && !(resCap(e.out)>0) ) { gw.next(e.out); } 1125 1125 while (gw.valid(e.v) && !gw.valid(e.out)) { 1126 1126 gw.next(e.v); 1127 1127 if (gw.valid(e.v)) gw.first(e.out, e.v); 1128 while (gw.valid(e.out) && !( free(e.out)>0) ) { gw.next(e.out); }1128 while (gw.valid(e.out) && !(resCap(e.out)>0) ) { gw.next(e.out); } 1129 1129 } 1130 1130 if (!gw.valid(e.out)) { 1131 1131 e.out_or_in=0; 1132 1132 gw.first(e.v); 1133 if (gw.valid(e.v)) gw.first(e.in, e.v); else e.in= /*OldInEdgeIt*/(INVALID);1134 while (gw.valid(e.in) && !( free(e.in)>0) ) { gw.next(e.in); }1133 if (gw.valid(e.v)) gw.first(e.in, e.v); else e.in=INVALID; 1134 while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); } 1135 1135 while (gw.valid(e.v) && !gw.valid(e.in)) { 1136 1136 gw.next(e.v); 1137 1137 if (gw.valid(e.v)) gw.first(e.in, e.v); 1138 while (gw.valid(e.in) && !( free(e.in)>0) ) { gw.next(e.in); }1138 while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); } 1139 1139 } 1140 1140 } 1141 1141 } else { 1142 1142 gw.next(e.in); 1143 while (gw.valid(e.in) && !( free(e.in)>0) ) { gw.next(e.in); }1143 while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); } 1144 1144 while (gw.valid(e.v) && !gw.valid(e.in)) { 1145 1145 gw.next(e.v); 1146 1146 if (gw.valid(e.v)) gw.first(e.in, e.v); 1147 while (gw.valid(e.in) && !( free(e.in)>0) ) { gw.next(e.in); }1147 while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); } 1148 1148 } 1149 1149 } … … 1194 1194 } 1195 1195 1196 Number free(const Edge& e) const {1196 Number resCap(const Edge& e) const { 1197 1197 if (e.out_or_in) 1198 1198 return (capacity->get(e.out)-flow->get(e.out)); … … 1201 1201 } 1202 1202 1203 Number free(OldOutEdgeIt out) const {1203 Number resCap(OldOutEdgeIt out) const { 1204 1204 return (capacity->get(out)-flow->get(out)); 1205 1205 } 1206 1206 1207 Number free(OldInEdgeIt in) const {1207 Number resCap(OldInEdgeIt in) const { 1208 1208 return (flow->get(in)); 1209 1209 } … … 1246 1246 } 1247 1247 }; 1248 }; 1249 1250 //Subgraph on the same node-set and partial edge-set 1251 template<typename GraphWrapper, typename FirstOutEdgesMap> 1252 class ErasingFirstGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> { 1253 protected: 1254 FirstOutEdgesMap* first_out_edges; 1255 public: 1256 typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node; 1257 typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt; 1258 typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge Edge; 1259 typedef typename GraphWrapperSkeleton<GraphWrapper>::EdgeIt EdgeIt; 1260 typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt InEdgeIt; 1261 typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt OutEdgeIt; 1262 1263 ErasingFirstGraphWrapper(GraphWrapper _gw, FirstOutEdgesMap& _first_out_edges) : 1264 GraphWrapperSkeleton<GraphWrapper>(_gw), first_out_edges(&_first_out_edges) { } 1265 1266 template<typename I> I& first(I& i) const { 1267 gw.first(i); 1268 //while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); } 1269 return i; 1270 } 1271 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { 1272 e=first_out_edges->get(n); 1273 return e; 1274 } 1275 template<typename I, typename P> I& first(I& i, const P& p) const { 1276 gw.first(i, p); 1277 //while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); } 1278 return i; 1279 } 1280 1281 //template<typename I> I getNext(const I& i) const { 1282 // return gw.getNext(i); 1283 //} 1284 template<typename I> I& next(I &i) const { 1285 gw.next(i); 1286 //while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); } 1287 return i; 1288 } 1289 1290 template< typename It > It first() const { 1291 It e; this->first(e); return e; } 1292 1293 template< typename It > It first(const Node& v) const { 1294 It e; this->first(e, v); return e; } 1295 1296 void erase(const OutEdgeIt& e) const { 1297 OutEdgeIt f=e; 1298 this->next(f); 1299 first_out_edges->set(this->tail(e), f); 1300 } 1248 1301 }; 1249 1302
Note: See TracChangeset
for help on using the changeset viewer.