768 |
768 |
769 |
769 |
770 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap> |
770 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap> |
771 class ResGraphWrapper { |
771 class ResGraphWrapper { |
772 public: |
772 public: |
773 typedef Graph BaseGraph; |
773 //typedef Graph BaseGraph; |
774 typedef typename Graph::Node Node; |
774 typedef typename Graph::Node Node; |
775 typedef typename Graph::NodeIt NodeIt; |
775 typedef typename Graph::NodeIt NodeIt; |
776 private: |
776 private: |
777 typedef typename Graph::OutEdgeIt OldOutEdgeIt; |
777 typedef typename Graph::OutEdgeIt OldOutEdgeIt; |
778 typedef typename Graph::InEdgeIt OldInEdgeIt; |
778 typedef typename Graph::InEdgeIt OldInEdgeIt; |
779 protected: |
779 protected: |
780 const Graph* graph; |
780 //const Graph* graph; |
|
781 typedef TrivGraphWrapper<const Graph> GraphWrapper; |
|
782 GraphWrapper gw; |
781 FlowMap* flow; |
783 FlowMap* flow; |
782 const CapacityMap* capacity; |
784 const CapacityMap* capacity; |
783 public: |
785 public: |
784 |
786 |
785 ResGraphWrapper(const Graph& _G, FlowMap& _flow, |
787 ResGraphWrapper(const Graph& _G, FlowMap& _flow, |
786 const CapacityMap& _capacity) : |
788 const CapacityMap& _capacity) : |
787 graph(&_G), flow(&_flow), capacity(&_capacity) { } |
789 gw(_G), flow(&_flow), capacity(&_capacity) { } |
788 |
790 |
789 void setGraph(const Graph& _graph) { graph = &_graph; } |
791 //void setGraph(const Graph& _graph) { graph = &_graph; } |
790 const Graph& getGraph() const { return (*graph); } |
792 //const Graph& getGraph() const { return (*graph); } |
791 |
793 |
792 class Edge; |
794 class Edge; |
793 class OutEdgeIt; |
795 class OutEdgeIt; |
794 friend class Edge; |
796 friend class Edge; |
795 friend class OutEdgeIt; |
797 friend class OutEdgeIt; |
862 public: |
864 public: |
863 EdgeIt() { } |
865 EdgeIt() { } |
864 //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { } |
866 //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { } |
865 EdgeIt(const Invalid& i) : Edge(i) { } |
867 EdgeIt(const Invalid& i) : Edge(i) { } |
866 EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() { |
868 EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() { |
867 resG.graph->first(v); |
869 resG.gw.first(v); |
868 if (resG.graph->valid(v)) resG.graph->first(out, v); else out=OldOutEdgeIt(INVALID); |
870 if (resG.gw.valid(v)) resG.gw.first(out, v); else out=/*OldOutEdgeIt*/(INVALID); |
869 while (resG.graph->valid(out) && !(resG.free(out)>0) ) { resG.graph->next(out); } |
871 while (resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); } |
870 while (resG.graph->valid(v) && !resG.graph->valid(out)) { |
872 while (resG.gw.valid(v) && !resG.gw.valid(out)) { |
871 resG.graph->next(v); |
873 resG.gw.next(v); |
872 if (resG.graph->valid(v)) resG.graph->first(out, v); |
874 if (resG.gw.valid(v)) resG.gw.first(out, v); |
873 while (resG.graph->valid(out) && !(resG.free(out)>0) ) { resG.graph->next(out); } |
875 while (resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); } |
874 } |
876 } |
875 if (!resG.graph->valid(out)) { |
877 if (!resG.gw.valid(out)) { |
876 out_or_in=0; |
878 out_or_in=0; |
877 resG.graph->first(v); |
879 resG.gw.first(v); |
878 if (resG.graph->valid(v)) resG.graph->first(in, v); else in=OldInEdgeIt(INVALID); |
880 if (resG.gw.valid(v)) resG.gw.first(in, v); else in=/*OldInEdgeIt*/(INVALID); |
879 while (resG.graph->valid(in) && !(resG.free(in)>0) ) { resG.graph->next(in); } |
881 while (resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); } |
880 while (resG.graph->valid(v) && !resG.graph->valid(in)) { |
882 while (resG.gw.valid(v) && !resG.gw.valid(in)) { |
881 resG.graph->next(v); |
883 resG.gw.next(v); |
882 if (resG.graph->valid(v)) resG.graph->first(in, v); |
884 if (resG.gw.valid(v)) resG.gw.first(in, v); |
883 while (resG.graph->valid(in) && !(resG.free(in)>0) ) { resG.graph->next(in); } |
885 while (resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); } |
884 } |
886 } |
885 } |
887 } |
886 } |
888 } |
887 // EdgeIt& operator++() { |
889 // EdgeIt& operator++() { |
888 // if (out_or_in) { |
890 // if (out_or_in) { |
915 // } |
917 // } |
916 // return *this; |
918 // return *this; |
917 // } |
919 // } |
918 }; |
920 }; |
919 |
921 |
920 NodeIt& first(NodeIt& v) const { return graph->first(v); } |
922 NodeIt& first(NodeIt& v) const { return gw.first(v); } |
921 OutEdgeIt& first(OutEdgeIt& e, Node v) const { |
923 OutEdgeIt& first(OutEdgeIt& e, Node v) const { |
922 e=OutEdgeIt(*this, v); |
924 e=OutEdgeIt(*this, v); |
923 return e; |
925 return e; |
924 } |
926 } |
925 EdgeIt& first(EdgeIt& e) const { |
927 EdgeIt& first(EdgeIt& e) const { |
926 e=EdgeIt(*this); |
928 e=EdgeIt(*this); |
927 return e; |
929 return e; |
928 } |
930 } |
929 |
931 |
930 NodeIt& next(NodeIt& n) const { return graph->next(n); } |
932 NodeIt& next(NodeIt& n) const { return gw.next(n); } |
931 |
933 |
932 OutEdgeIt& next(OutEdgeIt& e) const { |
934 OutEdgeIt& next(OutEdgeIt& e) const { |
933 if (e.out_or_in) { |
935 if (e.out_or_in) { |
934 Node v=graph->aNode(e.out); |
936 Node v=gw.aNode(e.out); |
935 graph->next(e.out); |
937 gw.next(e.out); |
936 while( graph->valid(e.out) && !(free(e.out)>0) ) { graph->next(e.out); } |
938 while( gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); } |
937 if (!graph->valid(e.out)) { |
939 if (!gw.valid(e.out)) { |
938 e.out_or_in=0; |
940 e.out_or_in=0; |
939 graph->first(e.in, v); |
941 gw.first(e.in, v); |
940 while( graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); } |
942 while( gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); } |
941 } |
943 } |
942 } else { |
944 } else { |
943 graph->next(e.in); |
945 gw.next(e.in); |
944 while( graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); } |
946 while( gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); } |
945 } |
947 } |
946 return e; |
948 return e; |
947 } |
949 } |
948 |
950 |
949 EdgeIt& next(EdgeIt& e) const { |
951 EdgeIt& next(EdgeIt& e) const { |
950 if (e.out_or_in) { |
952 if (e.out_or_in) { |
951 graph->next(e.out); |
953 gw.next(e.out); |
952 while (graph->valid(e.out) && !(free(e.out)>0) ) { graph->next(e.out); } |
954 while (gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); } |
953 while (graph->valid(e.v) && !graph->valid(e.out)) { |
955 while (gw.valid(e.v) && !gw.valid(e.out)) { |
954 graph->next(e.v); |
956 gw.next(e.v); |
955 if (graph->valid(e.v)) graph->first(e.out, e.v); |
957 if (gw.valid(e.v)) gw.first(e.out, e.v); |
956 while (graph->valid(e.out) && !(free(e.out)>0) ) { graph->next(e.out); } |
958 while (gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); } |
957 } |
959 } |
958 if (!graph->valid(e.out)) { |
960 if (!gw.valid(e.out)) { |
959 e.out_or_in=0; |
961 e.out_or_in=0; |
960 graph->first(e.v); |
962 gw.first(e.v); |
961 if (graph->valid(e.v)) graph->first(e.in, e.v); else e.in=OldInEdgeIt(INVALID); |
963 if (gw.valid(e.v)) gw.first(e.in, e.v); else e.in=/*OldInEdgeIt*/(INVALID); |
962 while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); } |
964 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); } |
963 while (graph->valid(e.v) && !graph->valid(e.in)) { |
965 while (gw.valid(e.v) && !gw.valid(e.in)) { |
964 graph->next(e.v); |
966 gw.next(e.v); |
965 if (graph->valid(e.v)) graph->first(e.in, e.v); |
967 if (gw.valid(e.v)) gw.first(e.in, e.v); |
966 while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); } |
968 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); } |
967 } |
969 } |
968 } |
970 } |
969 } else { |
971 } else { |
970 graph->next(e.in); |
972 gw.next(e.in); |
971 while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); } |
973 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); } |
972 while (graph->valid(e.v) && !graph->valid(e.in)) { |
974 while (gw.valid(e.v) && !gw.valid(e.in)) { |
973 graph->next(e.v); |
975 gw.next(e.v); |
974 if (graph->valid(e.v)) graph->first(e.in, e.v); |
976 if (gw.valid(e.v)) gw.first(e.in, e.v); |
975 while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); } |
977 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); } |
976 } |
978 } |
977 } |
979 } |
978 return e; |
980 return e; |
979 } |
981 } |
980 |
982 |
992 first(e, v); |
994 first(e, v); |
993 return e; |
995 return e; |
994 } |
996 } |
995 |
997 |
996 Node tail(Edge e) const { |
998 Node tail(Edge e) const { |
997 return ((e.out_or_in) ? graph->aNode(e.out) : graph->aNode(e.in)); } |
999 return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); } |
998 Node head(Edge e) const { |
1000 Node head(Edge e) const { |
999 return ((e.out_or_in) ? graph->bNode(e.out) : graph->bNode(e.in)); } |
1001 return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); } |
1000 |
1002 |
1001 Node aNode(OutEdgeIt e) const { |
1003 Node aNode(OutEdgeIt e) const { |
1002 return ((e.out_or_in) ? graph->aNode(e.out) : graph->aNode(e.in)); } |
1004 return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); } |
1003 Node bNode(OutEdgeIt e) const { |
1005 Node bNode(OutEdgeIt e) const { |
1004 return ((e.out_or_in) ? graph->bNode(e.out) : graph->bNode(e.in)); } |
1006 return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); } |
1005 |
1007 |
1006 int id(Node v) const { return graph->id(v); } |
1008 int id(Node v) const { return gw.id(v); } |
1007 |
1009 |
1008 bool valid(Node n) const { return graph->valid(n); } |
1010 bool valid(Node n) const { return gw.valid(n); } |
1009 bool valid(Edge e) const { |
1011 bool valid(Edge e) const { |
1010 return e.out_or_in ? graph->valid(e.out) : graph->valid(e.in); } |
1012 return e.out_or_in ? gw.valid(e.out) : gw.valid(e.in); } |
1011 |
1013 |
1012 void augment(const Edge& e, Number a) const { |
1014 void augment(const Edge& e, Number a) const { |
1013 if (e.out_or_in) |
1015 if (e.out_or_in) |
1014 flow->set(e.out, flow->get(e.out)+a); |
1016 flow->set(e.out, flow->get(e.out)+a); |
1015 else |
1017 else |
1049 // T get(Node nit) const { return node_map.get(nit); } |
1051 // T get(Node nit) const { return node_map.get(nit); } |
1050 // }; |
1052 // }; |
1051 |
1053 |
1052 template <typename T> |
1054 template <typename T> |
1053 class EdgeMap { |
1055 class EdgeMap { |
1054 typename Graph::EdgeMap<T> forward_map, backward_map; |
1056 typename GraphWrapper::EdgeMap<T> forward_map, backward_map; |
1055 public: |
1057 public: |
1056 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.getGraph()), backward_map(_G.getGraph()) { } |
1058 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { } |
1057 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.getGraph(), a), backward_map(_G.getGraph(), a) { } |
1059 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { } |
1058 void set(Edge e, T a) { |
1060 void set(Edge e, T a) { |
1059 if (e.out_or_in) |
1061 if (e.out_or_in) |
1060 forward_map.set(e.out, a); |
1062 forward_map.set(e.out, a); |
1061 else |
1063 else |
1062 backward_map.set(e.in, a); |
1064 backward_map.set(e.in, a); |
1125 //ROSSZ template<typename I> I& first(I& i) const { return first(i); } |
1127 //ROSSZ template<typename I> I& first(I& i) const { return first(i); } |
1126 //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const { |
1128 //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const { |
1127 // return first(i, p); } |
1129 // return first(i, p); } |
1128 |
1130 |
1129 //template<typename I> I getNext(const I& i) const { |
1131 //template<typename I> I getNext(const I& i) const { |
1130 // return graph->getNext(i); } |
1132 // return gw.getNext(i); } |
1131 //template<typename I> I& next(I &i) const { return graph->next(i); } |
1133 //template<typename I> I& next(I &i) const { return gw.next(i); } |
1132 |
1134 |
1133 template< typename It > It first() const { |
1135 template< typename It > It first() const { |
1134 It e; first(e); return e; } |
1136 It e; first(e); return e; } |
1135 |
1137 |
1136 template< typename It > It first(const Node& v) const { |
1138 template< typename It > It first(const Node& v) const { |
1137 It e; first(e, v); return e; } |
1139 It e; first(e, v); return e; } |
1138 |
1140 |
1139 //Node head(const Edge& e) const { return graph->head(e); } |
1141 //Node head(const Edge& e) const { return gw.head(e); } |
1140 //Node tail(const Edge& e) const { return graph->tail(e); } |
1142 //Node tail(const Edge& e) const { return gw.tail(e); } |
1141 |
1143 |
1142 //template<typename I> bool valid(const I& i) const |
1144 //template<typename I> bool valid(const I& i) const |
1143 // { return graph->valid(i); } |
1145 // { return gw.valid(i); } |
1144 |
1146 |
1145 //int nodeNum() const { return graph->nodeNum(); } |
1147 //int nodeNum() const { return gw.nodeNum(); } |
1146 //int edgeNum() const { return graph->edgeNum(); } |
1148 //int edgeNum() const { return gw.edgeNum(); } |
1147 |
1149 |
1148 //template<typename I> Node aNode(const I& e) const { |
1150 //template<typename I> Node aNode(const I& e) const { |
1149 // return graph->aNode(e); } |
1151 // return gw.aNode(e); } |
1150 //template<typename I> Node bNode(const I& e) const { |
1152 //template<typename I> Node bNode(const I& e) const { |
1151 // return graph->bNode(e); } |
1153 // return gw.bNode(e); } |
1152 |
1154 |
1153 //Node addNode() const { return graph->addNode(); } |
1155 //Node addNode() const { return gw.addNode(); } |
1154 //Edge addEdge(const Node& tail, const Node& head) const { |
1156 //Edge addEdge(const Node& tail, const Node& head) const { |
1155 // return graph->addEdge(tail, head); } |
1157 // return gw.addEdge(tail, head); } |
1156 |
1158 |
1157 //void erase(const OutEdgeIt& e) { |
1159 //void erase(const OutEdgeIt& e) { |
1158 // first_out_edge(this->tail(e))=e; |
1160 // first_out_edge(this->tail(e))=e; |
1159 //} |
1161 //} |
1160 void erase(const Edge& e) { |
1162 void erase(const Edge& e) { |
1161 OutEdgeIt f(e); |
1163 OutEdgeIt f(e); |
1162 next(f); |
1164 next(f); |
1163 first_out_edges.set(this->tail(e), f); |
1165 first_out_edges.set(this->tail(e), f); |
1164 } |
1166 } |
1165 //template<typename I> void erase(const I& i) const { graph->erase(i); } |
1167 //template<typename I> void erase(const I& i) const { gw.erase(i); } |
1166 |
1168 |
1167 //void clear() const { graph->clear(); } |
1169 //void clear() const { gw.clear(); } |
1168 |
1170 |
1169 template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { |
1171 template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { |
1170 public: |
1172 public: |
1171 NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : |
1173 NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : |
1172 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { } |
1174 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { } |
1207 //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges; |
1209 //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges; |
1208 |
1210 |
1209 public: |
1211 public: |
1210 FilterGraphWrapper(const Graph& _G, FlowMap& _flow, |
1212 FilterGraphWrapper(const Graph& _G, FlowMap& _flow, |
1211 const CapacityMap& _capacity) : |
1213 const CapacityMap& _capacity) : |
1212 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, graph->nodeNum()) { |
1214 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) { |
1213 } |
1215 } |
1214 |
1216 |
1215 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { |
1217 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { |
1216 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n); |
1218 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n); |
1217 while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e)))) |
1219 while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e)))) |
1246 //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { } |
1248 //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { } |
1247 |
1249 |
1248 //void setGraph(Graph& _graph) { graph = &_graph; } |
1250 //void setGraph(Graph& _graph) { graph = &_graph; } |
1249 //Graph& getGraph() const { return (*graph); } |
1251 //Graph& getGraph() const { return (*graph); } |
1250 |
1252 |
1251 //template<typename I> I& first(I& i) const { return graph->first(i); } |
1253 //template<typename I> I& first(I& i) const { return gw.first(i); } |
1252 //template<typename I, typename P> I& first(I& i, const P& p) const { |
1254 //template<typename I, typename P> I& first(I& i, const P& p) const { |
1253 // return graph->first(i, p); } |
1255 // return gw.first(i, p); } |
1254 |
1256 |
1255 //template<typename I> I getNext(const I& i) const { |
1257 //template<typename I> I getNext(const I& i) const { |
1256 // return graph->getNext(i); } |
1258 // return gw.getNext(i); } |
1257 //template<typename I> I& next(I &i) const { return graph->next(i); } |
1259 //template<typename I> I& next(I &i) const { return gw.next(i); } |
1258 |
1260 |
1259 template< typename It > It first() const { |
1261 template< typename It > It first() const { |
1260 It e; first(e); return e; } |
1262 It e; first(e); return e; } |
1261 |
1263 |
1262 template< typename It > It first(const Node& v) const { |
1264 template< typename It > It first(const Node& v) const { |
1263 It e; first(e, v); return e; } |
1265 It e; first(e, v); return e; } |
1264 |
1266 |
1265 //Node head(const Edge& e) const { return graph->head(e); } |
1267 //Node head(const Edge& e) const { return gw.head(e); } |
1266 //Node tail(const Edge& e) const { return graph->tail(e); } |
1268 //Node tail(const Edge& e) const { return gw.tail(e); } |
1267 |
1269 |
1268 //template<typename I> bool valid(const I& i) const |
1270 //template<typename I> bool valid(const I& i) const |
1269 // { return graph->valid(i); } |
1271 // { return gw.valid(i); } |
1270 |
1272 |
1271 //template<typename I> void setInvalid(const I &i); |
1273 //template<typename I> void setInvalid(const I &i); |
1272 //{ return graph->setInvalid(i); } |
1274 //{ return gw.setInvalid(i); } |
1273 |
1275 |
1274 //int nodeNum() const { return graph->nodeNum(); } |
1276 //int nodeNum() const { return gw.nodeNum(); } |
1275 //int edgeNum() const { return graph->edgeNum(); } |
1277 //int edgeNum() const { return gw.edgeNum(); } |
1276 |
1278 |
1277 //template<typename I> Node aNode(const I& e) const { |
1279 //template<typename I> Node aNode(const I& e) const { |
1278 // return graph->aNode(e); } |
1280 // return gw.aNode(e); } |
1279 //template<typename I> Node bNode(const I& e) const { |
1281 //template<typename I> Node bNode(const I& e) const { |
1280 // return graph->bNode(e); } |
1282 // return gw.bNode(e); } |
1281 |
1283 |
1282 //Node addNode() const { return graph->addNode(); } |
1284 //Node addNode() const { return gw.addNode(); } |
1283 //Edge addEdge(const Node& tail, const Node& head) const { |
1285 //Edge addEdge(const Node& tail, const Node& head) const { |
1284 // return graph->addEdge(tail, head); } |
1286 // return gw.addEdge(tail, head); } |
1285 |
1287 |
1286 //template<typename I> void erase(const I& i) const { graph->erase(i); } |
1288 //template<typename I> void erase(const I& i) const { gw.erase(i); } |
1287 |
1289 |
1288 //void clear() const { graph->clear(); } |
1290 //void clear() const { gw.clear(); } |
1289 |
1291 |
1290 template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { |
1292 template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { |
1291 public: |
1293 public: |
1292 NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : |
1294 NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : |
1293 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { } |
1295 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { } |
1339 // typename Graph::InEdgeIt i; |
1341 // typename Graph::InEdgeIt i; |
1340 // }; |
1342 // }; |
1341 // typedef typename Graph::SymEdgeIt SymEdgeIt; |
1343 // typedef typename Graph::SymEdgeIt SymEdgeIt; |
1342 // typedef typename Graph::EdgeIt EdgeIt; |
1344 // typedef typename Graph::EdgeIt EdgeIt; |
1343 |
1345 |
1344 // int nodeNum() const { return graph->nodeNum(); } |
1346 // int nodeNum() const { return gw.nodeNum(); } |
1345 // int edgeNum() const { return graph->edgeNum(); } |
1347 // int edgeNum() const { return gw.edgeNum(); } |
1346 |
1348 |
1347 // Node& first(Node& n) const { return graph->first(n); } |
1349 // Node& first(Node& n) const { return gw.first(n); } |
1348 |
1350 |
1349 // // Edge and SymEdge is missing!!!! |
1351 // // Edge and SymEdge is missing!!!! |
1350 // // Edge <-> In/OutEdgeIt conversion is missing!!!! |
1352 // // Edge <-> In/OutEdgeIt conversion is missing!!!! |
1351 |
1353 |
1352 // //FIXME |
1354 // //FIXME |
1353 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const |
1355 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const |
1354 // { |
1356 // { |
1355 // e.n=n; |
1357 // e.n=n; |
1356 // graph->first(e.o,n); |
1358 // gw.first(e.o,n); |
1357 // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) |
1359 // while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) |
1358 // graph->goNext(e.o); |
1360 // gw.goNext(e.o); |
1359 // if(!graph->valid(e.o)) { |
1361 // if(!gw.valid(e.o)) { |
1360 // graph->first(e.i,n); |
1362 // gw.first(e.i,n); |
1361 // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) |
1363 // while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) |
1362 // graph->goNext(e.i); |
1364 // gw.goNext(e.i); |
1363 // } |
1365 // } |
1364 // return e; |
1366 // return e; |
1365 // } |
1367 // } |
1366 // /* |
1368 // /* |
1367 // OutEdgeIt &goNext(OutEdgeIt &e) |
1369 // OutEdgeIt &goNext(OutEdgeIt &e) |
1368 // { |
1370 // { |
1369 // if(graph->valid(e.o)) { |
1371 // if(gw.valid(e.o)) { |
1370 // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) |
1372 // while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) |
1371 // graph->goNext(e.o); |
1373 // gw.goNext(e.o); |
1372 // if(graph->valid(e.o)) return e; |
1374 // if(gw.valid(e.o)) return e; |
1373 // else graph->first(e.i,e.n); |
1375 // else gw.first(e.i,e.n); |
1374 // } |
1376 // } |
1375 // else { |
1377 // else { |
1376 // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) |
1378 // while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) |
1377 // graph->goNext(e.i); |
1379 // gw.goNext(e.i); |
1378 // return e; |
1380 // return e; |
1379 // } |
1381 // } |
1380 // } |
1382 // } |
1381 // OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} |
1383 // OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} |
1382 // */ |
1384 // */ |
1383 // //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} |
1385 // //bool valid(const OutEdgeIt e) { return gw.valid(e.o)||gw.valid(e.i);} |
1384 |
1386 |
1385 // //FIXME |
1387 // //FIXME |
1386 // InEdgeIt& first(InEdgeIt& e, const Node& n) const |
1388 // InEdgeIt& first(InEdgeIt& e, const Node& n) const |
1387 // { |
1389 // { |
1388 // e.n=n; |
1390 // e.n=n; |
1389 // graph->first(e.i,n); |
1391 // gw.first(e.i,n); |
1390 // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) |
1392 // while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) |
1391 // graph->goNext(e.i); |
1393 // gw.goNext(e.i); |
1392 // if(!graph->valid(e.i)) { |
1394 // if(!gw.valid(e.i)) { |
1393 // graph->first(e.o,n); |
1395 // gw.first(e.o,n); |
1394 // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) |
1396 // while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) |
1395 // graph->goNext(e.o); |
1397 // gw.goNext(e.o); |
1396 // } |
1398 // } |
1397 // return e; |
1399 // return e; |
1398 // } |
1400 // } |
1399 // /* |
1401 // /* |
1400 // InEdgeIt &goNext(InEdgeIt &e) |
1402 // InEdgeIt &goNext(InEdgeIt &e) |
1401 // { |
1403 // { |
1402 // if(graph->valid(e.i)) { |
1404 // if(gw.valid(e.i)) { |
1403 // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) |
1405 // while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) |
1404 // graph->goNext(e.i); |
1406 // gw.goNext(e.i); |
1405 // if(graph->valid(e.i)) return e; |
1407 // if(gw.valid(e.i)) return e; |
1406 // else graph->first(e.o,e.n); |
1408 // else gw.first(e.o,e.n); |
1407 // } |
1409 // } |
1408 // else { |
1410 // else { |
1409 // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) |
1411 // while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) |
1410 // graph->goNext(e.o); |
1412 // gw.goNext(e.o); |
1411 // return e; |
1413 // return e; |
1412 // } |
1414 // } |
1413 // } |
1415 // } |
1414 // InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} |
1416 // InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} |
1415 // */ |
1417 // */ |
1416 // //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} |
1418 // //bool valid(const InEdgeIt e) { return gw.valid(e.i)||gw.valid(e.o);} |
1417 |
1419 |
1418 // //template<typename I> I &goNext(I &i); { return graph->goNext(i); } |
1420 // //template<typename I> I &goNext(I &i); { return gw.goNext(i); } |
1419 // //template<typename I> I next(const I i); { return graph->goNext(i); } |
1421 // //template<typename I> I next(const I i); { return gw.goNext(i); } |
1420 |
1422 |
1421 // template< typename It > It first() const { |
1423 // template< typename It > It first() const { |
1422 // It e; first(e); return e; } |
1424 // It e; first(e); return e; } |
1423 |
1425 |
1424 // template< typename It > It first(Node v) const { |
1426 // template< typename It > It first(Node v) const { |
1425 // It e; first(e, v); return e; } |
1427 // It e; first(e, v); return e; } |
1426 |
1428 |
1427 // Node head(const Edge& e) const { return graph->head(e); } |
1429 // Node head(const Edge& e) const { return gw.head(e); } |
1428 // Node tail(const Edge& e) const { return graph->tail(e); } |
1430 // Node tail(const Edge& e) const { return gw.tail(e); } |
1429 |
1431 |
1430 // template<typename I> Node aNode(const I& e) const { |
1432 // template<typename I> Node aNode(const I& e) const { |
1431 // return graph->aNode(e); } |
1433 // return gw.aNode(e); } |
1432 // template<typename I> Node bNode(const I& e) const { |
1434 // template<typename I> Node bNode(const I& e) const { |
1433 // return graph->bNode(e); } |
1435 // return gw.bNode(e); } |
1434 |
1436 |
1435 // //template<typename I> bool valid(const I i); |
1437 // //template<typename I> bool valid(const I i); |
1436 // //{ return graph->valid(i); } |
1438 // //{ return gw.valid(i); } |
1437 |
1439 |
1438 // //template<typename I> void setInvalid(const I &i); |
1440 // //template<typename I> void setInvalid(const I &i); |
1439 // //{ return graph->setInvalid(i); } |
1441 // //{ return gw.setInvalid(i); } |
1440 |
1442 |
1441 // Node addNode() { return graph->addNode(); } |
1443 // Node addNode() { return gw.addNode(); } |
1442 // Edge addEdge(const Node& tail, const Node& head) { |
1444 // Edge addEdge(const Node& tail, const Node& head) { |
1443 // return graph->addEdge(tail, head); } |
1445 // return gw.addEdge(tail, head); } |
1444 |
1446 |
1445 // template<typename I> void erase(const I& i) { graph->erase(i); } |
1447 // template<typename I> void erase(const I& i) { gw.erase(i); } |
1446 |
1448 |
1447 // void clear() { graph->clear(); } |
1449 // void clear() { gw.clear(); } |
1448 |
1450 |
1449 // template<typename S> class NodeMap : public Graph::NodeMap<S> { }; |
1451 // template<typename S> class NodeMap : public Graph::NodeMap<S> { }; |
1450 // template<typename S> class EdgeMap : public Graph::EdgeMap<S> { }; |
1452 // template<typename S> class EdgeMap : public Graph::EdgeMap<S> { }; |
1451 |
1453 |
1452 // void setGraph(Graph& _graph) { graph = &_graph; } |
1454 // void setGraph(Graph& _graph) { graph = &_graph; } |