[Lemon-commits] [lemon_svn] marci: r372 - in hugo/trunk/src/work: . marci
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:39:05 CET 2006
Author: marci
Date: Tue Mar 30 19:16:53 2004
New Revision: 372
Modified:
hugo/trunk/src/work/edmonds_karp.h
hugo/trunk/src/work/marci/edmonds_karp_demo.cc
hugo/trunk/src/work/marci/graph_wrapper.h
Log:
GraphWrappers, MapWrappers
Modified: hugo/trunk/src/work/edmonds_karp.h
==============================================================================
--- hugo/trunk/src/work/edmonds_karp.h (original)
+++ hugo/trunk/src/work/edmonds_karp.h Tue Mar 30 19:16:53 2004
@@ -247,30 +247,32 @@
};
- template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+ template <typename GraphWrapper, typename Number, typename FlowMap, typename CapacityMap>
class MaxFlow {
public:
- typedef typename Graph::Node Node;
- typedef typename Graph::Edge Edge;
- typedef typename Graph::EdgeIt EdgeIt;
- typedef typename Graph::OutEdgeIt OutEdgeIt;
- typedef typename Graph::InEdgeIt InEdgeIt;
+ typedef typename GraphWrapper::Node Node;
+ typedef typename GraphWrapper::Edge Edge;
+ typedef typename GraphWrapper::EdgeIt EdgeIt;
+ typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
+ typedef typename GraphWrapper::InEdgeIt InEdgeIt;
private:
- const Graph* G;
+ //const Graph* G;
+ GraphWrapper gw;
Node s;
Node t;
FlowMap* flow;
const CapacityMap* capacity;
- typedef ResGraphWrapper<Graph, Number, FlowMap, CapacityMap > AugGraph;
+ typedef ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap >
+ AugGraph;
typedef typename AugGraph::OutEdgeIt AugOutEdgeIt;
typedef typename AugGraph::Edge AugEdge;
public:
- MaxFlow(const Graph& _G, Node _s, Node _t, FlowMap& _flow, const CapacityMap& _capacity) :
- G(&_G), s(_s), t(_t), flow(&_flow), capacity(&_capacity) { }
+ MaxFlow(const GraphWrapper& _gw, Node _s, Node _t, FlowMap& _flow, const CapacityMap& _capacity) :
+ gw(_gw), s(_s), t(_t), flow(&_flow), capacity(&_capacity) { }
bool augmentOnShortestPath() {
- AugGraph res_graph(*G, *flow, *capacity);
+ AugGraph res_graph(gw, *flow, *capacity);
bool _augment=false;
typedef typename AugGraph::NodeMap<bool> ReachedMap;
@@ -313,131 +315,24 @@
return _augment;
}
-// template<typename MutableGraph> bool augmentOnBlockingFlow() {
-// bool _augment=false;
-
-// AugGraph res_graph(*G, *flow, *capacity);
-
-// typedef typename AugGraph::NodeMap<bool> ReachedMap;
-// BfsIterator5< AugGraph /*, AugOutEdgeIt*/, ReachedMap > bfs(res_graph);
-
-// bfs.pushAndSetReached(s);
-// typename AugGraph::NodeMap<int> dist(res_graph); //filled up with 0's
-// while ( !bfs.finished() ) {
-// AugOutEdgeIt e=bfs;
-// if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
-// dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
-// }
-
-// ++bfs;
-// } //computing distances from s in the residual graph
-
-// MutableGraph F;
-// typename AugGraph::NodeMap<typename MutableGraph::Node>
-// res_graph_to_F(res_graph);
-// for(typename AugGraph::NodeIt n=res_graph.template first<typename AugGraph::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
-// res_graph_to_F.set(n, F.addNode());
-// }
-
-// typename MutableGraph::Node sF=res_graph_to_F.get(s);
-// typename MutableGraph::Node tF=res_graph_to_F.get(t);
-
-// typename MutableGraph::EdgeMap<AugEdge> original_edge(F);
-// typename MutableGraph::EdgeMap<Number> residual_capacity(F);
-
-// //Making F to the graph containing the edges of the residual graph
-// //which are in some shortest paths
-// for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
-// if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
-// typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
-// original_edge.update();
-// original_edge.set(f, e);
-// residual_capacity.update();
-// residual_capacity.set(f, res_graph.free(e));
-// }
-// }
-
-// bool __augment=true;
-
-// while (__augment) {
-// __augment=false;
-// //computing blocking flow with dfs
-// typedef typename TrivGraphWrapper<MutableGraph>::NodeMap<bool> BlockingReachedMap;
-// DfsIterator5< TrivGraphWrapper<MutableGraph>/*, typename MutableGraph::OutEdgeIt*/, BlockingReachedMap > dfs(F);
-// typename MutableGraph::NodeMap<typename MutableGraph::Edge> pred(F);
-// pred.set(sF, typename MutableGraph::Edge(INVALID));
-// //invalid iterators for sources
-
-// typename MutableGraph::NodeMap<Number> free(F);
-
-// dfs.pushAndSetReached(sF);
-// while (!dfs.finished()) {
-// ++dfs;
-// if (F.valid(typename MutableGraph::OutEdgeIt(dfs))) {
-// if (dfs.isBNodeNewlyReached()) {
-// typename MutableGraph::Node v=F.aNode(dfs);
-// typename MutableGraph::Node w=F.bNode(dfs);
-// pred.set(w, dfs);
-// if (F.valid(pred.get(v))) {
-// free.set(w, std::min(free.get(v), residual_capacity.get(dfs)));
-// } else {
-// free.set(w, residual_capacity.get(dfs));
-// }
-// if (w==tF) {
-// __augment=true;
-// _augment=true;
-// break;
-// }
-
-// } else {
-// F.erase(typename MutableGraph::OutEdgeIt(dfs));
-// }
-// }
-// }
-
-// if (__augment) {
-// typename MutableGraph::Node n=tF;
-// Number augment_value=free.get(tF);
-// while (F.valid(pred.get(n))) {
-// typename MutableGraph::Edge e=pred.get(n);
-// res_graph.augment(original_edge.get(e), augment_value);
-// n=F.tail(e);
-// if (residual_capacity.get(e)==augment_value)
-// F.erase(e);
-// else
-// residual_capacity.set(e, residual_capacity.get(e)-augment_value);
-// }
-// }
-
-// }
-
-// return _augment;
-// }
-
- template<typename GraphWrapper>
+ template<typename MapGraphWrapper>
class DistanceMap {
protected:
- GraphWrapper gw;
- typename GraphWrapper::NodeMap<int> dist;
+ MapGraphWrapper gw;
+ typename MapGraphWrapper::NodeMap<int> dist;
public:
- DistanceMap(GraphWrapper& _gw) : gw(_gw), dist(_gw, _gw.nodeNum()) { }
- //NodeMap(const ListGraph& _G, T a) :
- //G(_G), container(G.node_id, a) { }
- void set(const typename GraphWrapper::Node& n, int a) { dist[n]=a; }
- int get(const typename GraphWrapper::Node& n) const { return dist[n]; }
- bool get(const typename GraphWrapper::Edge& e) const {
+ DistanceMap(MapGraphWrapper& _gw) : gw(_gw), dist(_gw, _gw.nodeNum()) { }
+ void set(const typename MapGraphWrapper::Node& n, int a) { dist[n]=a; }
+ int get(const typename MapGraphWrapper::Node& n) const { return dist[n]; }
+ bool get(const typename MapGraphWrapper::Edge& e) const {
return (dist.get(gw.tail(e))<dist.get(gw.head(e)));
}
- //typename std::vector<T>::reference operator[](Node n) {
- //return container[/*G.id(n)*/n.node->id]; }
- //typename std::vector<T>::const_reference operator[](Node n) const {
- //return container[/*G.id(n)*/n.node->id];
};
template<typename MutableGraph> bool augmentOnBlockingFlow() {
bool _augment=false;
- AugGraph res_graph(*G, *flow, *capacity);
+ AugGraph res_graph(gw, *flow, *capacity);
typedef typename AugGraph::NodeMap<bool> ReachedMap;
BfsIterator5< AugGraph, ReachedMap > bfs(res_graph);
@@ -453,34 +348,9 @@
++bfs;
} //computing distances from s in the residual graph
-// MutableGraph F;
-// typename AugGraph::NodeMap<typename MutableGraph::Node>
-// res_graph_to_F(res_graph);
-// for(typename AugGraph::NodeIt n=res_graph.template first<typename AugGraph::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
-// res_graph_to_F.set(n, F.addNode());
-// }
-
-// typename MutableGraph::Node sF=res_graph_to_F.get(s);
-// typename MutableGraph::Node tF=res_graph_to_F.get(t);
-
-// typename MutableGraph::EdgeMap<AugEdge> original_edge(F);
-// typename MutableGraph::EdgeMap<Number> residual_capacity(F);
-
-// //Making F to the graph containing the edges of the residual graph
-// //which are in some shortest paths
-// for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
-// if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
-// typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
-// original_edge.update();
-// original_edge.set(f, e);
-// residual_capacity.update();
-// residual_capacity.set(f, res_graph.free(e));
-// }
-// }
-
MutableGraph F;
- //typedef SubGraphWrapper<AugGraph, DistanceMap<AugGraph> > FilterResGraph;
- //FilterResGraph filter_res_graph(res_graph, dist);
+ typedef SubGraphWrapper<AugGraph, DistanceMap<AugGraph> > FilterResGraph;
+ FilterResGraph filter_res_graph(res_graph, dist);
typename AugGraph::NodeMap<typename MutableGraph::Node>
res_graph_to_F(res_graph);
for(typename AugGraph::NodeIt n=res_graph.template first<typename AugGraph::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
@@ -495,16 +365,14 @@
//Making F to the graph containing the edges of the residual graph
//which are in some shortest paths
- for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>();
- res_graph.valid(e);
- res_graph.next(e)) {
- if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
+ for(typename FilterResGraph::EdgeIt e=filter_res_graph.template first<typename FilterResGraph::EdgeIt>(); filter_res_graph.valid(e); filter_res_graph.next(e)) {
+ //if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
original_edge.update();
original_edge.set(f, e);
residual_capacity.update();
residual_capacity.set(f, res_graph.free(e));
- }
+ //}
}
bool __augment=true;
@@ -541,410 +409,83 @@
} else {
F.erase(typename MutableGraph::OutEdgeIt(dfs));
- }
- }
- }
-
- if (__augment) {
- typename MutableGraph::Node n=tF;
- Number augment_value=free.get(tF);
- while (F.valid(pred.get(n))) {
- typename MutableGraph::Edge e=pred.get(n);
- res_graph.augment(original_edge.get(e), augment_value);
- n=F.tail(e);
- if (residual_capacity.get(e)==augment_value)
- F.erase(e);
- else
- residual_capacity.set(e, residual_capacity.get(e)-augment_value);
- }
- }
-
- }
-
- return _augment;
- }
-
- template<typename MutableGraph> bool augmentOnBlockingFlow1() {
- bool _augment=false;
-
- AugGraph res_graph(*G, *flow, *capacity);
-
- //bfs for distances on the residual graph
- typedef typename AugGraph::NodeMap<bool> ReachedMap;
- BfsIterator5< AugGraph, ReachedMap > bfs(res_graph);
- bfs.pushAndSetReached(s);
- typename AugGraph::NodeMap<int> dist(res_graph); //filled up with 0's
-
- //F will contain the physical copy of the residual graph
- //with the set of edges which areon shortest paths
- MutableGraph F;
- typename AugGraph::NodeMap<typename MutableGraph::Node>
- res_graph_to_F(res_graph);
- for(typename AugGraph::NodeIt n=res_graph.template first<typename AugGraph::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
- res_graph_to_F.set(n, F.addNode());
- }
- typename MutableGraph::Node sF=res_graph_to_F.get(s);
- typename MutableGraph::Node tF=res_graph_to_F.get(t);
- typename MutableGraph::EdgeMap<AugEdge> original_edge(F);
- typename MutableGraph::EdgeMap<Number> residual_capacity(F);
-
- while ( !bfs.finished() ) {
- AugOutEdgeIt e=bfs;
- if (res_graph.valid(e)) {
- if (bfs.isBNodeNewlyReached()) {
- dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
- typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
- original_edge.update();
- original_edge.set(f, e);
- residual_capacity.update();
- residual_capacity.set(f, res_graph.free(e));
- } else {
- if (dist.get(res_graph.head(e))==(dist.get(res_graph.tail(e))+1)) {
- typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
- original_edge.update();
- original_edge.set(f, e);
- residual_capacity.update();
- residual_capacity.set(f, res_graph.free(e));
- }
- }
- }
- ++bfs;
- } //computing distances from s in the residual graph
-
- bool __augment=true;
-
- while (__augment) {
- __augment=false;
- //computing blocking flow with dfs
- typedef typename TrivGraphWrapper<MutableGraph>::NodeMap<bool> BlockingReachedMap;
- DfsIterator5< TrivGraphWrapper<MutableGraph>/*, typename MutableGraph::OutEdgeIt*/, BlockingReachedMap > dfs(F);
- typename MutableGraph::NodeMap<typename MutableGraph::Edge> pred(F);
- pred.set(sF, typename MutableGraph::Edge(INVALID));
- //invalid iterators for sources
-
- typename MutableGraph::NodeMap<Number> free(F);
-
- dfs.pushAndSetReached(sF);
- while (!dfs.finished()) {
- ++dfs;
- if (F.valid(typename MutableGraph::OutEdgeIt(dfs))) {
- if (dfs.isBNodeNewlyReached()) {
- typename MutableGraph::Node v=F.aNode(dfs);
- typename MutableGraph::Node w=F.bNode(dfs);
- pred.set(w, dfs);
- if (F.valid(pred.get(v))) {
- free.set(w, std::min(free.get(v), residual_capacity.get(dfs)));
- } else {
- free.set(w, residual_capacity.get(dfs));
- }
- if (w==tF) {
- __augment=true;
- _augment=true;
- break;
- }
-
- } else {
- F.erase(typename MutableGraph::OutEdgeIt(dfs));
- }
- }
- }
-
- if (__augment) {
- typename MutableGraph::Node n=tF;
- Number augment_value=free.get(tF);
- while (F.valid(pred.get(n))) {
- typename MutableGraph::Edge e=pred.get(n);
- res_graph.augment(original_edge.get(e), augment_value);
- n=F.tail(e);
- if (residual_capacity.get(e)==augment_value)
- F.erase(e);
- else
- residual_capacity.set(e, residual_capacity.get(e)-augment_value);
- }
- }
-
- }
-
- return _augment;
- }
- bool augmentOnBlockingFlow2() {
- bool _augment=false;
-
- //typedef ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> EAugGraph;
- typedef FilterGraphWrapper< ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > EAugGraph;
- typedef typename EAugGraph::OutEdgeIt EAugOutEdgeIt;
- typedef typename EAugGraph::Edge EAugEdge;
-
- EAugGraph res_graph(*G, *flow, *capacity);
-
- //typedef typename EAugGraph::NodeMap<bool> ReachedMap;
- BfsIterator5<
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>,
- /*typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt,*/
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<bool> > bfs(res_graph);
-
- bfs.pushAndSetReached(s);
-
- typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::
- NodeMap<int>& dist=res_graph.dist;
-
- while ( !bfs.finished() ) {
- typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
- if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
- dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
- }
- ++bfs;
- } //computing distances from s in the residual graph
-
- bool __augment=true;
-
- while (__augment) {
-
- __augment=false;
- //computing blocking flow with dfs
- typedef typename EAugGraph::NodeMap<bool> BlockingReachedMap;
- DfsIterator5< EAugGraph/*, EAugOutEdgeIt*/, BlockingReachedMap >
- dfs(res_graph);
- typename EAugGraph::NodeMap<EAugEdge> pred(res_graph);
- pred.set(s, EAugEdge(INVALID));
- //invalid iterators for sources
-
- typename EAugGraph::NodeMap<Number> free(res_graph);
-
- dfs.pushAndSetReached(s);
- while (!dfs.finished()) {
- ++dfs;
- if (res_graph.valid(EAugOutEdgeIt(dfs))) {
- if (dfs.isBNodeNewlyReached()) {
-
- typename EAugGraph::Node v=res_graph.aNode(dfs);
- typename EAugGraph::Node w=res_graph.bNode(dfs);
-
- pred.set(w, EAugOutEdgeIt(dfs));
- if (res_graph.valid(pred.get(v))) {
- free.set(w, std::min(free.get(v), res_graph.free(dfs)));
- } else {
- free.set(w, res_graph.free(dfs));
- }
-
- if (w==t) {
- __augment=true;
- _augment=true;
- break;
- }
- } else {
- res_graph.erase(dfs);
- }
- }
-
- }
-
- if (__augment) {
- typename EAugGraph::Node n=t;
- Number augment_value=free.get(t);
- while (res_graph.valid(pred.get(n))) {
- EAugEdge e=pred.get(n);
- res_graph.augment(e, augment_value);
- n=res_graph.tail(e);
- if (res_graph.free(e)==0)
- res_graph.erase(e);
- }
- }
-
- }
-
- return _augment;
- }
- void run() {
- //int num_of_augmentations=0;
- while (augmentOnShortestPath()) {
- //while (augmentOnBlockingFlow<MutableGraph>()) {
- //std::cout << ++num_of_augmentations << " ";
- //std::cout<<std::endl;
- }
- }
- template<typename MutableGraph> void run() {
- //int num_of_augmentations=0;
- //while (augmentOnShortestPath()) {
- while (augmentOnBlockingFlow<MutableGraph>()) {
- //std::cout << ++num_of_augmentations << " ";
- //std::cout<<std::endl;
- }
- }
- Number flowValue() {
- Number a=0;
- OutEdgeIt e;
- for(G->/*getF*/first(e, s); G->valid(e); G->next(e)) {
- a+=flow->get(e);
- }
- return a;
- }
- };
-
-
- template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
- class MaxMatching {
- public:
- typedef typename Graph::Node Node;
- typedef typename Graph::NodeIt NodeIt;
- typedef typename Graph::Edge Edge;
- typedef typename Graph::EdgeIt EdgeIt;
- typedef typename Graph::OutEdgeIt OutEdgeIt;
- typedef typename Graph::InEdgeIt InEdgeIt;
-
- typedef typename Graph::NodeMap<bool> SMap;
- typedef typename Graph::NodeMap<bool> TMap;
- private:
- const Graph* G;
- SMap* S;
- TMap* T;
- //Node s;
- //Node t;
- FlowMap* flow;
- const CapacityMap* capacity;
- typedef ResGraphWrapper<Graph, Number, FlowMap, CapacityMap > AugGraph;
- typedef typename AugGraph::OutEdgeIt AugOutEdgeIt;
- typedef typename AugGraph::Edge AugEdge;
- typename Graph::NodeMap<int> used; //0
-
- public:
- MaxMatching(const Graph& _G, SMap& _S, TMap& _T, FlowMap& _flow, const CapacityMap& _capacity) :
- G(&_G), S(&_S), T(&_T), flow(&_flow), capacity(&_capacity), used(_G) { }
- bool augmentOnShortestPath() {
- AugGraph res_graph(*G, *flow, *capacity);
- bool _augment=false;
-
- typedef typename AugGraph::NodeMap<bool> ReachedMap;
- BfsIterator5< AugGraph, /*AugOutEdgeIt,*/ ReachedMap > res_bfs(res_graph);
- typename AugGraph::NodeMap<AugEdge> pred(res_graph);
- for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
- if ((S->get(s)) && (used.get(s)<1) ) {
- //Number u=0;
- //for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
- //u+=flow->get(e);
- //if (u<1) {
- res_bfs.pushAndSetReached(s);
- pred.set(s, AugEdge(INVALID));
- //}
- }
- }
-
- typename AugGraph::NodeMap<Number> free(res_graph);
-
- Node n;
- //searching for augmenting path
- while ( !res_bfs.finished() ) {
- AugOutEdgeIt e=res_bfs;
- if (res_graph.valid(e) && res_bfs.isBNodeNewlyReached()) {
- Node v=res_graph.tail(e);
- Node w=res_graph.head(e);
- pred.set(w, e);
- if (res_graph.valid(pred.get(v))) {
- free.set(w, std::min(free.get(v), res_graph.free(e)));
- } else {
- free.set(w, res_graph.free(e));
- }
- n=res_graph.head(e);
- if (T->get(n) && (used.get(n)<1) ) {
- //Number u=0;
- //for(InEdgeIt f=G->template first<InEdgeIt>(n); G->valid(f); G->next(f))
- //u+=flow->get(f);
- //if (u<1) {
- _augment=true;
- break;
- //}
- }
+ }
+ }
}
-
- ++res_bfs;
- } //end of searching augmenting path
- if (_augment) {
- //Node n=t;
- used.set(n, 1); //mind2 vegen jav
- Number augment_value=free.get(n);
- while (res_graph.valid(pred.get(n))) {
- AugEdge e=pred.get(n);
- res_graph.augment(e, augment_value);
- n=res_graph.tail(e);
+ if (__augment) {
+ typename MutableGraph::Node n=tF;
+ Number augment_value=free.get(tF);
+ while (F.valid(pred.get(n))) {
+ typename MutableGraph::Edge e=pred.get(n);
+ res_graph.augment(original_edge.get(e), augment_value);
+ n=F.tail(e);
+ if (residual_capacity.get(e)==augment_value)
+ F.erase(e);
+ else
+ residual_capacity.set(e, residual_capacity.get(e)-augment_value);
+ }
}
- used.set(n, 1); //mind2 vegen jav
+
}
-
+
return _augment;
}
-// template<typename MutableGraph> bool augmentOnBlockingFlow() {
+// template<typename MutableGraph> bool augmentOnBlockingFlow1() {
// bool _augment=false;
// AugGraph res_graph(*G, *flow, *capacity);
+// //bfs for distances on the residual graph
// typedef typename AugGraph::NodeMap<bool> ReachedMap;
-// BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > bfs(res_graph);
-
-
-
-
-
-// //typename AugGraph::NodeMap<AugEdge> pred(res_graph);
-// for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
-// if (S->get(s)) {
-// Number u=0;
-// for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
-// u+=flow->get(e);
-// if (u<1) {
-// res_bfs.pushAndSetReached(s);
-// //pred.set(s, AugEdge(INVALID));
-// }
-// }
-// }
-
-
-
-
-// //bfs.pushAndSetReached(s);
+// BfsIterator5< AugGraph, ReachedMap > bfs(res_graph);
+// bfs.pushAndSetReached(s);
// typename AugGraph::NodeMap<int> dist(res_graph); //filled up with 0's
-// while ( !bfs.finished() ) {
-// AugOutEdgeIt e=bfs;
-// if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
-// dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
-// }
-
-// ++bfs;
-// } //computing distances from s in the residual graph
+// //F will contain the physical copy of the residual graph
+// //with the set of edges which areon shortest paths
// MutableGraph F;
// typename AugGraph::NodeMap<typename MutableGraph::Node>
// res_graph_to_F(res_graph);
// for(typename AugGraph::NodeIt n=res_graph.template first<typename AugGraph::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
// res_graph_to_F.set(n, F.addNode());
// }
-
// typename MutableGraph::Node sF=res_graph_to_F.get(s);
// typename MutableGraph::Node tF=res_graph_to_F.get(t);
-
// typename MutableGraph::EdgeMap<AugEdge> original_edge(F);
// typename MutableGraph::EdgeMap<Number> residual_capacity(F);
-// //Making F to the graph containing the edges of the residual graph
-// //which are in some shortest paths
-// for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
-// if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
-// typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
-// original_edge.update();
-// original_edge.set(f, e);
-// residual_capacity.update();
-// residual_capacity.set(f, res_graph.free(e));
-// }
-// }
+// while ( !bfs.finished() ) {
+// AugOutEdgeIt e=bfs;
+// if (res_graph.valid(e)) {
+// if (bfs.isBNodeNewlyReached()) {
+// dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
+// typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
+// original_edge.update();
+// original_edge.set(f, e);
+// residual_capacity.update();
+// residual_capacity.set(f, res_graph.free(e));
+// } else {
+// if (dist.get(res_graph.head(e))==(dist.get(res_graph.tail(e))+1)) {
+// typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
+// original_edge.update();
+// original_edge.set(f, e);
+// residual_capacity.update();
+// residual_capacity.set(f, res_graph.free(e));
+// }
+// }
+// }
+// ++bfs;
+// } //computing distances from s in the residual graph
// bool __augment=true;
// while (__augment) {
// __augment=false;
// //computing blocking flow with dfs
-// typedef typename MutableGraph::NodeMap<bool> BlockingReachedMap;
-// DfsIterator4< MutableGraph, typename MutableGraph::OutEdgeIt, BlockingReachedMap > dfs(F);
+// typedef typename TrivGraphWrapper<MutableGraph>::NodeMap<bool> BlockingReachedMap;
+// DfsIterator5< TrivGraphWrapper<MutableGraph>/*, typename MutableGraph::OutEdgeIt*/, BlockingReachedMap > dfs(F);
// typename MutableGraph::NodeMap<typename MutableGraph::Edge> pred(F);
// pred.set(sF, typename MutableGraph::Edge(INVALID));
// //invalid iterators for sources
@@ -994,140 +535,102 @@
// return _augment;
// }
- bool augmentOnBlockingFlow2() {
- bool _augment=false;
-
- //typedef ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> EAugGraph;
- typedef FilterGraphWrapper< ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > EAugGraph;
- typedef typename EAugGraph::OutEdgeIt EAugOutEdgeIt;
- typedef typename EAugGraph::Edge EAugEdge;
-
- EAugGraph res_graph(*G, *flow, *capacity);
-
- //typedef typename EAugGraph::NodeMap<bool> ReachedMap;
- BfsIterator5<
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>,
- /*typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt,*/
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<bool> > bfs(res_graph);
-
-
- //typename AugGraph::NodeMap<AugEdge> pred(res_graph);
- for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
- if (S->get(s)) {
- Number u=0;
- for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
- u+=flow->get(e);
- if (u<1) {
- bfs.pushAndSetReached(s);
- //pred.set(s, AugEdge(INVALID));
- }
- }
- }
+// bool augmentOnBlockingFlow2() {
+// bool _augment=false;
+// //typedef ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> EAugGraph;
+// typedef FilterGraphWrapper< ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > EAugGraph;
+// typedef typename EAugGraph::OutEdgeIt EAugOutEdgeIt;
+// typedef typename EAugGraph::Edge EAugEdge;
+
+// EAugGraph res_graph(*G, *flow, *capacity);
+
+// //typedef typename EAugGraph::NodeMap<bool> ReachedMap;
+// BfsIterator5<
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>,
+// /*typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt,*/
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<bool> > bfs(res_graph);
- //bfs.pushAndSetReached(s);
-
- typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::
- NodeMap<int>& dist=res_graph.dist;
-
- while ( !bfs.finished() ) {
- typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
- if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
- dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
- }
- ++bfs;
- } //computing distances from s in the residual graph
-
- bool __augment=true;
-
- while (__augment) {
+// bfs.pushAndSetReached(s);
- __augment=false;
- //computing blocking flow with dfs
- typedef typename EAugGraph::NodeMap<bool> BlockingReachedMap;
- DfsIterator5< EAugGraph/*, EAugOutEdgeIt*/, BlockingReachedMap >
- dfs(res_graph);
- typename EAugGraph::NodeMap<EAugEdge> pred(res_graph, INVALID);
- //pred.set(s, EAugEdge(INVALID));
- //invalid iterators for sources
+// typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::
+// NodeMap<int>& dist=res_graph.dist;
- typename EAugGraph::NodeMap<Number> free(res_graph);
+// while ( !bfs.finished() ) {
+// typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
+// if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
+// dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
+// }
+// ++bfs;
+// } //computing distances from s in the residual graph
+// bool __augment=true;
- //typename AugGraph::NodeMap<AugEdge> pred(res_graph);
- for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
- if (S->get(s)) {
- Number u=0;
- for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
- u+=flow->get(e);
- if (u<1) {
- dfs.pushAndSetReached(s);
- //pred.set(s, AugEdge(INVALID));
- }
- }
- }
+// while (__augment) {
+// __augment=false;
+// //computing blocking flow with dfs
+// typedef typename EAugGraph::NodeMap<bool> BlockingReachedMap;
+// DfsIterator5< EAugGraph/*, EAugOutEdgeIt*/, BlockingReachedMap >
+// dfs(res_graph);
+// typename EAugGraph::NodeMap<EAugEdge> pred(res_graph);
+// pred.set(s, EAugEdge(INVALID));
+// //invalid iterators for sources
+// typename EAugGraph::NodeMap<Number> free(res_graph);
- //dfs.pushAndSetReached(s);
- typename EAugGraph::Node n;
- while (!dfs.finished()) {
- ++dfs;
- if (res_graph.valid(EAugOutEdgeIt(dfs))) {
- if (dfs.isBNodeNewlyReached()) {
+// dfs.pushAndSetReached(s);
+// while (!dfs.finished()) {
+// ++dfs;
+// if (res_graph.valid(EAugOutEdgeIt(dfs))) {
+// if (dfs.isBNodeNewlyReached()) {
- typename EAugGraph::Node v=res_graph.aNode(dfs);
- typename EAugGraph::Node w=res_graph.bNode(dfs);
+// typename EAugGraph::Node v=res_graph.aNode(dfs);
+// typename EAugGraph::Node w=res_graph.bNode(dfs);
- pred.set(w, EAugOutEdgeIt(dfs));
- if (res_graph.valid(pred.get(v))) {
- free.set(w, std::min(free.get(v), res_graph.free(dfs)));
- } else {
- free.set(w, res_graph.free(dfs));
- }
-
- n=w;
- if (T->get(w)) {
- Number u=0;
- for(InEdgeIt f=G->template first<InEdgeIt>(n); G->valid(f); G->next(f))
- u+=flow->get(f);
- if (u<1) {
- __augment=true;
- _augment=true;
- break;
- }
- }
- } else {
- res_graph.erase(dfs);
- }
- }
+// pred.set(w, EAugOutEdgeIt(dfs));
+// if (res_graph.valid(pred.get(v))) {
+// free.set(w, std::min(free.get(v), res_graph.free(dfs)));
+// } else {
+// free.set(w, res_graph.free(dfs));
+// }
+
+// if (w==t) {
+// __augment=true;
+// _augment=true;
+// break;
+// }
+// } else {
+// res_graph.erase(dfs);
+// }
+// }
- }
+// }
- if (__augment) {
- // typename EAugGraph::Node n=t;
- Number augment_value=free.get(n);
- while (res_graph.valid(pred.get(n))) {
- EAugEdge e=pred.get(n);
- res_graph.augment(e, augment_value);
- n=res_graph.tail(e);
- if (res_graph.free(e)==0)
- res_graph.erase(e);
- }
- }
+// if (__augment) {
+// typename EAugGraph::Node n=t;
+// Number augment_value=free.get(t);
+// while (res_graph.valid(pred.get(n))) {
+// EAugEdge e=pred.get(n);
+// res_graph.augment(e, augment_value);
+// n=res_graph.tail(e);
+// if (res_graph.free(e)==0)
+// res_graph.erase(e);
+// }
+// }
- }
+// }
- return _augment;
- }
- void run() {
- //int num_of_augmentations=0;
- while (augmentOnShortestPath()) {
- //while (augmentOnBlockingFlow<MutableGraph>()) {
- //std::cout << ++num_of_augmentations << " ";
- //std::cout<<std::endl;
- }
- }
+// return _augment;
+// }
+// void run() {
+// //int num_of_augmentations=0;
+// while (augmentOnShortestPath()) {
+// //while (augmentOnBlockingFlow<MutableGraph>()) {
+// //std::cout << ++num_of_augmentations << " ";
+// //std::cout<<std::endl;
+// }
+// }
// template<typename MutableGraph> void run() {
// //int num_of_augmentations=0;
// //while (augmentOnShortestPath()) {
@@ -1135,11 +638,11 @@
// //std::cout << ++num_of_augmentations << " ";
// //std::cout<<std::endl;
// }
-// }
+// }
Number flowValue() {
Number a=0;
- EdgeIt e;
- for(G->/*getF*/first(e); G->valid(e); G->next(e)) {
+ OutEdgeIt e;
+ for(gw.first(e, s); gw.valid(e); gw.next(e)) {
a+=flow->get(e);
}
return a;
@@ -1147,74 +650,77 @@
};
-
-
-
-
// template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-// class MaxFlow2 {
+// class MaxMatching {
// public:
// typedef typename Graph::Node Node;
+// typedef typename Graph::NodeIt NodeIt;
// typedef typename Graph::Edge Edge;
// typedef typename Graph::EdgeIt EdgeIt;
// typedef typename Graph::OutEdgeIt OutEdgeIt;
// typedef typename Graph::InEdgeIt InEdgeIt;
+
+// typedef typename Graph::NodeMap<bool> SMap;
+// typedef typename Graph::NodeMap<bool> TMap;
// private:
-// const Graph& G;
-// std::list<Node>& S;
-// std::list<Node>& T;
-// FlowMap& flow;
-// const CapacityMap& capacity;
+// const Graph* G;
+// SMap* S;
+// TMap* T;
+// //Node s;
+// //Node t;
+// FlowMap* flow;
+// const CapacityMap* capacity;
// typedef ResGraphWrapper<Graph, Number, FlowMap, CapacityMap > AugGraph;
// typedef typename AugGraph::OutEdgeIt AugOutEdgeIt;
// typedef typename AugGraph::Edge AugEdge;
-// typename Graph::NodeMap<bool> SMap;
-// typename Graph::NodeMap<bool> TMap;
+// typename Graph::NodeMap<int> used; //0
+
// public:
-// MaxFlow2(const Graph& _G, std::list<Node>& _S, std::list<Node>& _T, FlowMap& _flow, const CapacityMap& _capacity) : G(_G), S(_S), T(_T), flow(_flow), capacity(_capacity), SMap(_G), TMap(_G) {
-// for(typename std::list<Node>::const_iterator i=S.begin();
-// i!=S.end(); ++i) {
-// SMap.set(*i, true);
-// }
-// for (typename std::list<Node>::const_iterator i=T.begin();
-// i!=T.end(); ++i) {
-// TMap.set(*i, true);
-// }
-// }
-// bool augment() {
-// AugGraph res_graph(G, flow, capacity);
+// MaxMatching(const Graph& _G, SMap& _S, TMap& _T, FlowMap& _flow, const CapacityMap& _capacity) :
+// G(&_G), S(&_S), T(&_T), flow(&_flow), capacity(&_capacity), used(_G) { }
+// bool augmentOnShortestPath() {
+// AugGraph res_graph(*G, *flow, *capacity);
// bool _augment=false;
-// Node reached_t_node;
// typedef typename AugGraph::NodeMap<bool> ReachedMap;
-// BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph);
-// for(typename std::list<Node>::const_iterator i=S.begin();
-// i!=S.end(); ++i) {
-// res_bfs.pushAndSetReached(*i);
-// }
-// //res_bfs.pushAndSetReached(s);
-
+// BfsIterator5< AugGraph, /*AugOutEdgeIt,*/ ReachedMap > res_bfs(res_graph);
// typename AugGraph::NodeMap<AugEdge> pred(res_graph);
-// //filled up with invalid iterators
+// for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
+// if ((S->get(s)) && (used.get(s)<1) ) {
+// //Number u=0;
+// //for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
+// //u+=flow->get(e);
+// //if (u<1) {
+// res_bfs.pushAndSetReached(s);
+// pred.set(s, AugEdge(INVALID));
+// //}
+// }
+// }
// typename AugGraph::NodeMap<Number> free(res_graph);
+// Node n;
// //searching for augmenting path
// while ( !res_bfs.finished() ) {
-// AugOutEdgeIt e=/*AugOutEdgeIt*/(res_bfs);
-// if (e.valid() && res_bfs.isBNodeNewlyReached()) {
+// AugOutEdgeIt e=res_bfs;
+// if (res_graph.valid(e) && res_bfs.isBNodeNewlyReached()) {
// Node v=res_graph.tail(e);
// Node w=res_graph.head(e);
// pred.set(w, e);
-// if (pred.get(v).valid()) {
-// free.set(w, std::min(free.get(v), e.free()));
+// if (res_graph.valid(pred.get(v))) {
+// free.set(w, std::min(free.get(v), res_graph.free(e)));
// } else {
-// free.set(w, e.free());
+// free.set(w, res_graph.free(e));
// }
-// if (TMap.get(res_graph.head(e))) {
-// _augment=true;
-// reached_t_node=res_graph.head(e);
-// break;
+// n=res_graph.head(e);
+// if (T->get(n) && (used.get(n)<1) ) {
+// //Number u=0;
+// //for(InEdgeIt f=G->template first<InEdgeIt>(n); G->valid(f); G->next(f))
+// //u+=flow->get(f);
+// //if (u<1) {
+// _augment=true;
+// break;
+// //}
// }
// }
@@ -1222,30 +728,287 @@
// } //end of searching augmenting path
// if (_augment) {
-// Node n=reached_t_node;
-// Number augment_value=free.get(reached_t_node);
-// while (pred.get(n).valid()) {
+// //Node n=t;
+// used.set(n, 1); //mind2 vegen jav
+// Number augment_value=free.get(n);
+// while (res_graph.valid(pred.get(n))) {
// AugEdge e=pred.get(n);
-// e.augment(augment_value);
+// res_graph.augment(e, augment_value);
// n=res_graph.tail(e);
// }
+// used.set(n, 1); //mind2 vegen jav
+// }
+
+// return _augment;
+// }
+
+// // template<typename MutableGraph> bool augmentOnBlockingFlow() {
+// // bool _augment=false;
+
+// // AugGraph res_graph(*G, *flow, *capacity);
+
+// // typedef typename AugGraph::NodeMap<bool> ReachedMap;
+// // BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > bfs(res_graph);
+
+
+
+
+
+// // //typename AugGraph::NodeMap<AugEdge> pred(res_graph);
+// // for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
+// // if (S->get(s)) {
+// // Number u=0;
+// // for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
+// // u+=flow->get(e);
+// // if (u<1) {
+// // res_bfs.pushAndSetReached(s);
+// // //pred.set(s, AugEdge(INVALID));
+// // }
+// // }
+// // }
+
+
+
+
+// // //bfs.pushAndSetReached(s);
+// // typename AugGraph::NodeMap<int> dist(res_graph); //filled up with 0's
+// // while ( !bfs.finished() ) {
+// // AugOutEdgeIt e=bfs;
+// // if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
+// // dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
+// // }
+
+// // ++bfs;
+// // } //computing distances from s in the residual graph
+
+// // MutableGraph F;
+// // typename AugGraph::NodeMap<typename MutableGraph::Node>
+// // res_graph_to_F(res_graph);
+// // for(typename AugGraph::NodeIt n=res_graph.template first<typename AugGraph::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
+// // res_graph_to_F.set(n, F.addNode());
+// // }
+
+// // typename MutableGraph::Node sF=res_graph_to_F.get(s);
+// // typename MutableGraph::Node tF=res_graph_to_F.get(t);
+
+// // typename MutableGraph::EdgeMap<AugEdge> original_edge(F);
+// // typename MutableGraph::EdgeMap<Number> residual_capacity(F);
+
+// // //Making F to the graph containing the edges of the residual graph
+// // //which are in some shortest paths
+// // for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
+// // if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
+// // typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
+// // original_edge.update();
+// // original_edge.set(f, e);
+// // residual_capacity.update();
+// // residual_capacity.set(f, res_graph.free(e));
+// // }
+// // }
+
+// // bool __augment=true;
+
+// // while (__augment) {
+// // __augment=false;
+// // //computing blocking flow with dfs
+// // typedef typename MutableGraph::NodeMap<bool> BlockingReachedMap;
+// // DfsIterator4< MutableGraph, typename MutableGraph::OutEdgeIt, BlockingReachedMap > dfs(F);
+// // typename MutableGraph::NodeMap<typename MutableGraph::Edge> pred(F);
+// // pred.set(sF, typename MutableGraph::Edge(INVALID));
+// // //invalid iterators for sources
+
+// // typename MutableGraph::NodeMap<Number> free(F);
+
+// // dfs.pushAndSetReached(sF);
+// // while (!dfs.finished()) {
+// // ++dfs;
+// // if (F.valid(typename MutableGraph::OutEdgeIt(dfs))) {
+// // if (dfs.isBNodeNewlyReached()) {
+// // typename MutableGraph::Node v=F.aNode(dfs);
+// // typename MutableGraph::Node w=F.bNode(dfs);
+// // pred.set(w, dfs);
+// // if (F.valid(pred.get(v))) {
+// // free.set(w, std::min(free.get(v), residual_capacity.get(dfs)));
+// // } else {
+// // free.set(w, residual_capacity.get(dfs));
+// // }
+// // if (w==tF) {
+// // __augment=true;
+// // _augment=true;
+// // break;
+// // }
+
+// // } else {
+// // F.erase(typename MutableGraph::OutEdgeIt(dfs));
+// // }
+// // }
+// // }
+
+// // if (__augment) {
+// // typename MutableGraph::Node n=tF;
+// // Number augment_value=free.get(tF);
+// // while (F.valid(pred.get(n))) {
+// // typename MutableGraph::Edge e=pred.get(n);
+// // res_graph.augment(original_edge.get(e), augment_value);
+// // n=F.tail(e);
+// // if (residual_capacity.get(e)==augment_value)
+// // F.erase(e);
+// // else
+// // residual_capacity.set(e, residual_capacity.get(e)-augment_value);
+// // }
+// // }
+
+// // }
+
+// // return _augment;
+// // }
+// bool augmentOnBlockingFlow2() {
+// bool _augment=false;
+
+// //typedef ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> EAugGraph;
+// typedef FilterGraphWrapper< ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > EAugGraph;
+// typedef typename EAugGraph::OutEdgeIt EAugOutEdgeIt;
+// typedef typename EAugGraph::Edge EAugEdge;
+
+// EAugGraph res_graph(*G, *flow, *capacity);
+
+// //typedef typename EAugGraph::NodeMap<bool> ReachedMap;
+// BfsIterator5<
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>,
+// /*typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt,*/
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<bool> > bfs(res_graph);
+
+
+// //typename AugGraph::NodeMap<AugEdge> pred(res_graph);
+// for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
+// if (S->get(s)) {
+// Number u=0;
+// for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
+// u+=flow->get(e);
+// if (u<1) {
+// bfs.pushAndSetReached(s);
+// //pred.set(s, AugEdge(INVALID));
+// }
+// }
// }
+
+// //bfs.pushAndSetReached(s);
+
+// typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::
+// NodeMap<int>& dist=res_graph.dist;
+
+// while ( !bfs.finished() ) {
+// typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
+// if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
+// dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
+// }
+// ++bfs;
+// } //computing distances from s in the residual graph
+
+// bool __augment=true;
+
+// while (__augment) {
+
+// __augment=false;
+// //computing blocking flow with dfs
+// typedef typename EAugGraph::NodeMap<bool> BlockingReachedMap;
+// DfsIterator5< EAugGraph/*, EAugOutEdgeIt*/, BlockingReachedMap >
+// dfs(res_graph);
+// typename EAugGraph::NodeMap<EAugEdge> pred(res_graph, INVALID);
+// //pred.set(s, EAugEdge(INVALID));
+// //invalid iterators for sources
+
+// typename EAugGraph::NodeMap<Number> free(res_graph);
+
+
+// //typename AugGraph::NodeMap<AugEdge> pred(res_graph);
+// for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
+// if (S->get(s)) {
+// Number u=0;
+// for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
+// u+=flow->get(e);
+// if (u<1) {
+// dfs.pushAndSetReached(s);
+// //pred.set(s, AugEdge(INVALID));
+// }
+// }
+// }
+
+
+
+// //dfs.pushAndSetReached(s);
+// typename EAugGraph::Node n;
+// while (!dfs.finished()) {
+// ++dfs;
+// if (res_graph.valid(EAugOutEdgeIt(dfs))) {
+// if (dfs.isBNodeNewlyReached()) {
+
+// typename EAugGraph::Node v=res_graph.aNode(dfs);
+// typename EAugGraph::Node w=res_graph.bNode(dfs);
+
+// pred.set(w, EAugOutEdgeIt(dfs));
+// if (res_graph.valid(pred.get(v))) {
+// free.set(w, std::min(free.get(v), res_graph.free(dfs)));
+// } else {
+// free.set(w, res_graph.free(dfs));
+// }
+
+// n=w;
+// if (T->get(w)) {
+// Number u=0;
+// for(InEdgeIt f=G->template first<InEdgeIt>(n); G->valid(f); G->next(f))
+// u+=flow->get(f);
+// if (u<1) {
+// __augment=true;
+// _augment=true;
+// break;
+// }
+// }
+// } else {
+// res_graph.erase(dfs);
+// }
+// }
+
+// }
+
+// if (__augment) {
+// // typename EAugGraph::Node n=t;
+// Number augment_value=free.get(n);
+// while (res_graph.valid(pred.get(n))) {
+// EAugEdge e=pred.get(n);
+// res_graph.augment(e, augment_value);
+// n=res_graph.tail(e);
+// if (res_graph.free(e)==0)
+// res_graph.erase(e);
+// }
+// }
+
+// }
+
// return _augment;
// }
// void run() {
-// while (augment()) { }
+// //int num_of_augmentations=0;
+// while (augmentOnShortestPath()) {
+// //while (augmentOnBlockingFlow<MutableGraph>()) {
+// //std::cout << ++num_of_augmentations << " ";
+// //std::cout<<std::endl;
+// }
// }
+// // template<typename MutableGraph> void run() {
+// // //int num_of_augmentations=0;
+// // //while (augmentOnShortestPath()) {
+// // while (augmentOnBlockingFlow<MutableGraph>()) {
+// // //std::cout << ++num_of_augmentations << " ";
+// // //std::cout<<std::endl;
+// // }
+// // }
// Number flowValue() {
// Number a=0;
-// for(typename std::list<Node>::const_iterator i=S.begin();
-// i!=S.end(); ++i) {
-// for(OutEdgeIt e=G.template first<OutEdgeIt>(*i); e.valid(); ++e) {
-// a+=flow.get(e);
-// }
-// for(InEdgeIt e=G.template first<InEdgeIt>(*i); e.valid(); ++e) {
-// a-=flow.get(e);
-// }
+// EdgeIt e;
+// for(G->/*getF*/first(e); G->valid(e); G->next(e)) {
+// a+=flow->get(e);
// }
// return a;
// }
@@ -1253,6 +1016,110 @@
+
+
+
+// // template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+// // class MaxFlow2 {
+// // public:
+// // typedef typename Graph::Node Node;
+// // typedef typename Graph::Edge Edge;
+// // typedef typename Graph::EdgeIt EdgeIt;
+// // typedef typename Graph::OutEdgeIt OutEdgeIt;
+// // typedef typename Graph::InEdgeIt InEdgeIt;
+// // private:
+// // const Graph& G;
+// // std::list<Node>& S;
+// // std::list<Node>& T;
+// // FlowMap& flow;
+// // const CapacityMap& capacity;
+// // typedef ResGraphWrapper<Graph, Number, FlowMap, CapacityMap > AugGraph;
+// // typedef typename AugGraph::OutEdgeIt AugOutEdgeIt;
+// // typedef typename AugGraph::Edge AugEdge;
+// // typename Graph::NodeMap<bool> SMap;
+// // typename Graph::NodeMap<bool> TMap;
+// // public:
+// // MaxFlow2(const Graph& _G, std::list<Node>& _S, std::list<Node>& _T, FlowMap& _flow, const CapacityMap& _capacity) : G(_G), S(_S), T(_T), flow(_flow), capacity(_capacity), SMap(_G), TMap(_G) {
+// // for(typename std::list<Node>::const_iterator i=S.begin();
+// // i!=S.end(); ++i) {
+// // SMap.set(*i, true);
+// // }
+// // for (typename std::list<Node>::const_iterator i=T.begin();
+// // i!=T.end(); ++i) {
+// // TMap.set(*i, true);
+// // }
+// // }
+// // bool augment() {
+// // AugGraph res_graph(G, flow, capacity);
+// // bool _augment=false;
+// // Node reached_t_node;
+
+// // typedef typename AugGraph::NodeMap<bool> ReachedMap;
+// // BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph);
+// // for(typename std::list<Node>::const_iterator i=S.begin();
+// // i!=S.end(); ++i) {
+// // res_bfs.pushAndSetReached(*i);
+// // }
+// // //res_bfs.pushAndSetReached(s);
+
+// // typename AugGraph::NodeMap<AugEdge> pred(res_graph);
+// // //filled up with invalid iterators
+
+// // typename AugGraph::NodeMap<Number> free(res_graph);
+
+// // //searching for augmenting path
+// // while ( !res_bfs.finished() ) {
+// // AugOutEdgeIt e=/*AugOutEdgeIt*/(res_bfs);
+// // if (e.valid() && res_bfs.isBNodeNewlyReached()) {
+// // Node v=res_graph.tail(e);
+// // Node w=res_graph.head(e);
+// // pred.set(w, e);
+// // if (pred.get(v).valid()) {
+// // free.set(w, std::min(free.get(v), e.free()));
+// // } else {
+// // free.set(w, e.free());
+// // }
+// // if (TMap.get(res_graph.head(e))) {
+// // _augment=true;
+// // reached_t_node=res_graph.head(e);
+// // break;
+// // }
+// // }
+
+// // ++res_bfs;
+// // } //end of searching augmenting path
+
+// // if (_augment) {
+// // Node n=reached_t_node;
+// // Number augment_value=free.get(reached_t_node);
+// // while (pred.get(n).valid()) {
+// // AugEdge e=pred.get(n);
+// // e.augment(augment_value);
+// // n=res_graph.tail(e);
+// // }
+// // }
+
+// // return _augment;
+// // }
+// // void run() {
+// // while (augment()) { }
+// // }
+// // Number flowValue() {
+// // Number a=0;
+// // for(typename std::list<Node>::const_iterator i=S.begin();
+// // i!=S.end(); ++i) {
+// // for(OutEdgeIt e=G.template first<OutEdgeIt>(*i); e.valid(); ++e) {
+// // a+=flow.get(e);
+// // }
+// // for(InEdgeIt e=G.template first<InEdgeIt>(*i); e.valid(); ++e) {
+// // a-=flow.get(e);
+// // }
+// // }
+// // return a;
+// // }
+// // };
+
+
} // namespace hugo
#endif //HUGO_EDMONDS_KARP_H
Modified: hugo/trunk/src/work/marci/edmonds_karp_demo.cc
==============================================================================
--- hugo/trunk/src/work/marci/edmonds_karp_demo.cc (original)
+++ hugo/trunk/src/work/marci/edmonds_karp_demo.cc Tue Mar 30 19:16:53 2004
@@ -9,6 +9,11 @@
#include <time_measure.h>
#include <graph_wrapper.h>
+class CM {
+public:
+ template<typename T> int get(T) const {return 1;}
+};
+
using namespace hugo;
// Use a DIMACS max flow file as stdin.
@@ -86,14 +91,17 @@
{
//std::cout << "SmartGraph..." << std::endl;
+ typedef TrivGraphWrapper<const Graph> GW;
+ GW gw(G);
std::cout << "edmonds karp demo (physical blocking flow augmentation)..." << std::endl;
- Graph::EdgeMap<int> flow(G); //0 flow
+ GW::EdgeMap<int> flow(G); //0 flow
Timer ts;
ts.reset();
- MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
- //max_flow_test.augmentWithBlockingFlow<Graph>();
+ typedef GW::EdgeMapWrapper< Graph::EdgeMap<int>, int > EMW;
+ EMW cw(cap);
+ MaxFlow<GW, int, GW::EdgeMap<int>, EMW > max_flow_test(G, s, t, flow, cw);
int i=0;
while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) {
// for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
@@ -113,72 +121,74 @@
std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
}
- {
- //std::cout << "SmartGraph..." << std::endl;
- std::cout << "edmonds karp demo (physical blocking flow 1 augmentation)..." << std::endl;
- Graph::EdgeMap<int> flow(G); //0 flow
-
- Timer ts;
- ts.reset();
-
- MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
- //max_flow_test.augmentWithBlockingFlow<Graph>();
- int i=0;
- while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
-// for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
-// std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// {
+// //std::cout << "SmartGraph..." << std::endl;
+// std::cout << "edmonds karp demo (physical blocking flow 1 augmentation)..." << std::endl;
+// Graph::EdgeMap<int> flow(G); //0 flow
+
+// Timer ts;
+// ts.reset();
+
+// MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
+// int i=0;
+// while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
+// // for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
+// // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// // }
+// // std::cout<<std::endl;
+// ++i;
// }
-// std::cout<<std::endl;
- ++i;
- }
-// std::cout << "maximum flow: "<< std::endl;
-// for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
-// std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// // std::cout << "maximum flow: "<< std::endl;
+// // for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
+// // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// // }
+// // std::cout<<std::endl;
+// std::cout << "elapsed time: " << ts << std::endl;
+// std::cout << "number of augmentation phases: " << i << std::endl;
+// std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
// }
-// std::cout<<std::endl;
- std::cout << "elapsed time: " << ts << std::endl;
- std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
- }
-
- {
- std::cout << "edmonds karp demo (on-the-fly blocking flow augmentation)..." << std::endl;
- Graph::EdgeMap<int> flow(G); //0 flow
-
- Timer ts;
- ts.reset();
- MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
- //max_flow_test.augmentWithBlockingFlow<Graph>();
- int i=0;
- while (max_flow_test.augmentOnBlockingFlow2()) {
-// for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
-// std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// {
+// std::cout << "edmonds karp demo (on-the-fly blocking flow augmentation)..." << std::endl;
+// Graph::EdgeMap<int> flow(G); //0 flow
+
+// Timer ts;
+// ts.reset();
+
+// MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
+// int i=0;
+// while (max_flow_test.augmentOnBlockingFlow2()) {
+// // for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
+// // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// // }
+// // std::cout<<std::endl;
+// ++i;
// }
-// std::cout<<std::endl;
- ++i;
- }
-// std::cout << "maximum flow: "<< std::endl;
-// for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
-// std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// // std::cout << "maximum flow: "<< std::endl;
+// // for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
+// // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+// // }
+// // std::cout<<std::endl;
+// std::cout << "elapsed time: " << ts << std::endl;
+// std::cout << "number of augmentation phases: " << i << std::endl;
+// std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
// }
-// std::cout<<std::endl;
- std::cout << "elapsed time: " << ts << std::endl;
- std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
- }
{
+ typedef TrivGraphWrapper<const Graph> GW;
+ GW gw(G);
std::cout << "edmonds karp demo (on-the-fly shortest path augmentation)..." << std::endl;
- Graph::EdgeMap<int> flow(G); //0 flow
+ GW::EdgeMap<int> flow(gw); //0 flow
Timer ts;
ts.reset();
- MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
- //max_flow_test.augmentWithBlockingFlow<Graph>();
+ //CM cm;
+ typedef GW::EdgeMapWrapper< Graph::EdgeMap<int>, int > EMW;
+ EMW cw(cap);
+ MaxFlow<GW, int, GW::EdgeMap<int>, EMW> max_flow_test(gw, s, t, flow, cw);
int i=0;
while (max_flow_test.augmentOnShortestPath()) {
// for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
Modified: hugo/trunk/src/work/marci/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/work/marci/graph_wrapper.h (original)
+++ hugo/trunk/src/work/marci/graph_wrapper.h Tue Mar 30 19:16:53 2004
@@ -123,7 +123,7 @@
template<typename T> class NodeMap : public Graph::NodeMap<T> {
public:
- NodeMap(const TrivGraphWrapper<Graph>& _G) :
+ NodeMap(const TrivGraphWrapper<Graph>& _G) :
Graph::NodeMap<T>(*(_G.graph)) { }
NodeMap(const TrivGraphWrapper<Graph>& _G, T a) :
Graph::NodeMap<T>(*(_G.graph), a) { }
@@ -131,11 +131,33 @@
template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
public:
- EdgeMap(const TrivGraphWrapper<Graph>& _G) :
+ EdgeMap(const TrivGraphWrapper<Graph>& _G) :
Graph::EdgeMap<T>(*(_G.graph)) { }
EdgeMap(const TrivGraphWrapper<Graph>& _G, T a) :
Graph::EdgeMap<T>(*(_G.graph), a) { }
};
+
+ template<typename Map, typename T> class NodeMapWrapper {
+ protected:
+ Map* map;
+ public:
+ NodeMapWrapper(Map& _map) : map(&_map) { }
+ //template<typename T>
+ void set(Node n, T a) { map->set(n, a); }
+ //template<typename T>
+ T get(Node n) const { return map->get(n); }
+ };
+
+ template<typename Map, typename T> class EdgeMapWrapper {
+ protected:
+ Map* map;
+ public:
+ EdgeMapWrapper(Map& _map) : map(&_map) { }
+ //template<typename T>
+ void set(Edge n, T a) { map->set(n, a); }
+ //template<typename T>
+ T get(Edge n) const { return map->get(n); }
+ };
};
template<typename GraphWrapper>
@@ -247,7 +269,7 @@
template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
public:
- NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
+ NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
GraphWrapper::NodeMap<T>(_G.gw) { }
NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) :
GraphWrapper::NodeMap<T>(_G.gw, a) { }
@@ -255,7 +277,7 @@
template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> {
public:
- EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
+ EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
GraphWrapper::EdgeMap<T>(_G.gw) { }
EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) :
GraphWrapper::EdgeMap<T>(_G.gw, a) { }
@@ -759,7 +781,7 @@
template<typename I> I& first(I& i) const { gw.first(i); return i; }
template<typename I, typename P> I& first(I& i, const P& p) const {
- graph->first(i, p); return i; }
+ gw.first(i, p); return i; }
OutEdgeIt& next(OutEdgeIt& e) const {
if (e.out_or_in) {
@@ -911,26 +933,27 @@
// };
- template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
- class ResGraphWrapper {
+ template<typename GraphWrapper, typename Number, typename FlowMap, typename CapacityMap>
+ class ResGraphWrapper : public GraphWrapperSkeleton<GraphWrapper>{
public:
//typedef Graph BaseGraph;
- typedef TrivGraphWrapper<const Graph> GraphWrapper;
- typedef typename GraphWrapper::Node Node;
- typedef typename GraphWrapper::NodeIt NodeIt;
+ //typedef TrivGraphWrapper<const Graph> GraphWrapper;
+ typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
+ typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
private:
- typedef typename GraphWrapper::OutEdgeIt OldOutEdgeIt;
- typedef typename GraphWrapper::InEdgeIt OldInEdgeIt;
+ typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt OldOutEdgeIt;
+ typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OldInEdgeIt;
protected:
//const Graph* graph;
- GraphWrapper gw;
+ //GraphWrapper gw;
FlowMap* flow;
const CapacityMap* capacity;
public:
- ResGraphWrapper(const Graph& _G, FlowMap& _flow,
- const CapacityMap& _capacity) :
- gw(_G), flow(&_flow), capacity(&_capacity) { }
+ ResGraphWrapper(const GraphWrapper& _gw, FlowMap& _flow,
+ const CapacityMap& _capacity) :
+ GraphWrapperSkeleton<GraphWrapper>(_gw),
+ flow(&_flow), capacity(&_capacity) { }
//void setGraph(const Graph& _graph) { graph = &_graph; }
//const Graph& getGraph() const { return (*graph); }
@@ -941,7 +964,7 @@
friend class OutEdgeIt;
class Edge {
- friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
+ friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
protected:
bool out_or_in; //true, iff out
OldOutEdgeIt out;
@@ -967,14 +990,14 @@
class OutEdgeIt : public Edge {
- friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
+ friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
public:
OutEdgeIt() { }
//FIXME
OutEdgeIt(const Edge& e) : Edge(e) { }
OutEdgeIt(const Invalid& i) : Edge(i) { }
protected:
- OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
+ OutEdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
resG.gw.first(out, v);
while( resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
if (!resG.gw.valid(out)) {
@@ -1006,13 +1029,13 @@
typedef void InEdgeIt;
class EdgeIt : public Edge {
- friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
+ friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
NodeIt v;
public:
EdgeIt() { }
//EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
EdgeIt(const Invalid& i) : Edge(i) { }
- EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() {
+ EdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG) : Edge() {
resG.gw.first(v);
if (resG.gw.valid(v)) resG.gw.first(out, v); else out=/*OldOutEdgeIt*/(INVALID);
while (resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
@@ -1066,7 +1089,7 @@
// }
};
- NodeIt& first(NodeIt& v) const { return gw.first(v); }
+ NodeIt& first(NodeIt& v) const { gw.first(v); return v; }
OutEdgeIt& first(OutEdgeIt& e, Node v) const {
e=OutEdgeIt(*this, v);
return e;
@@ -1185,13 +1208,13 @@
return (flow->get(in));
}
- template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
- public:
- NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G)
- : GraphWrapper::NodeMap<T>(_G.gw) { }
- NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G,
- T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }
- };
+// template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
+// public:
+// NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G)
+// : GraphWrapper::NodeMap<T>(_G.gw) { }
+// NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G,
+// T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }
+// };
// template <typename T>
// class NodeMap {
@@ -1207,8 +1230,8 @@
class EdgeMap {
typename GraphWrapper::EdgeMap<T> forward_map, backward_map;
public:
- EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }
- EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }
+ EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }
+ EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }
void set(Edge e, T a) {
if (e.out_or_in)
forward_map.set(e.out, a);
@@ -1224,243 +1247,243 @@
};
};
- template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
- class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
- protected:
- ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
- //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
- public:
- ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow,
- const CapacityMap& _capacity) :
- ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity),
- first_out_edges(*this) /*, dist(*this)*/ {
- for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
- OutEdgeIt e;
- ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
- first_out_edges.set(n, e);
- }
- }
+// template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+// class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
+// protected:
+// ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
+// //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
+// public:
+// ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow,
+// const CapacityMap& _capacity) :
+// ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity),
+// first_out_edges(*this) /*, dist(*this)*/ {
+// for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
+// OutEdgeIt e;
+// ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
+// first_out_edges.set(n, e);
+// }
+// }
- //void setGraph(Graph& _graph) { graph = &_graph; }
- //Graph& getGraph() const { return (*graph); }
+// //void setGraph(Graph& _graph) { graph = &_graph; }
+// //Graph& getGraph() const { return (*graph); }
- //TrivGraphWrapper() : graph(0) { }
- //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
+// //TrivGraphWrapper() : graph(0) { }
+// //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
- //typedef Graph BaseGraph;
+// //typedef Graph BaseGraph;
- //typedef typename Graph::Node Node;
- //typedef typename Graph::NodeIt NodeIt;
+// //typedef typename Graph::Node Node;
+// //typedef typename Graph::NodeIt NodeIt;
- //typedef typename Graph::Edge Edge;
- //typedef typename Graph::OutEdgeIt OutEdgeIt;
- //typedef typename Graph::InEdgeIt InEdgeIt;
- //typedef typename Graph::SymEdgeIt SymEdgeIt;
- //typedef typename Graph::EdgeIt EdgeIt;
-
- typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
- typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
-
- typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
- typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
- //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
- //typedef typename Graph::SymEdgeIt SymEdgeIt;
- //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
+// //typedef typename Graph::Edge Edge;
+// //typedef typename Graph::OutEdgeIt OutEdgeIt;
+// //typedef typename Graph::InEdgeIt InEdgeIt;
+// //typedef typename Graph::SymEdgeIt SymEdgeIt;
+// //typedef typename Graph::EdgeIt EdgeIt;
- NodeIt& first(NodeIt& n) const {
- return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
- }
+// typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
+// typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
- OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
- e=first_out_edges.get(n);
- return e;
- }
+// typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
+// typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
+// //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
+// //typedef typename Graph::SymEdgeIt SymEdgeIt;
+// //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
+
+// NodeIt& first(NodeIt& n) const {
+// return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
+// }
+
+// OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
+// e=first_out_edges.get(n);
+// return e;
+// }
- //ROSSZ template<typename I> I& first(I& i) const { return first(i); }
- //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const {
- // return first(i, p); }
+// //ROSSZ template<typename I> I& first(I& i) const { return first(i); }
+// //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const {
+// // return first(i, p); }
- //template<typename I> I getNext(const I& i) const {
- // return gw.getNext(i); }
- //template<typename I> I& next(I &i) const { return gw.next(i); }
+// //template<typename I> I getNext(const I& i) const {
+// // return gw.getNext(i); }
+// //template<typename I> I& next(I &i) const { return gw.next(i); }
- template< typename It > It first() const {
- It e; first(e); return e; }
+// template< typename It > It first() const {
+// It e; first(e); return e; }
- template< typename It > It first(const Node& v) const {
- It e; first(e, v); return e; }
+// template< typename It > It first(const Node& v) const {
+// It e; first(e, v); return e; }
- //Node head(const Edge& e) const { return gw.head(e); }
- //Node tail(const Edge& e) const { return gw.tail(e); }
+// //Node head(const Edge& e) const { return gw.head(e); }
+// //Node tail(const Edge& e) const { return gw.tail(e); }
- //template<typename I> bool valid(const I& i) const
- // { return gw.valid(i); }
+// //template<typename I> bool valid(const I& i) const
+// // { return gw.valid(i); }
- //int nodeNum() const { return gw.nodeNum(); }
- //int edgeNum() const { return gw.edgeNum(); }
+// //int nodeNum() const { return gw.nodeNum(); }
+// //int edgeNum() const { return gw.edgeNum(); }
- //template<typename I> Node aNode(const I& e) const {
- // return gw.aNode(e); }
- //template<typename I> Node bNode(const I& e) const {
- // return gw.bNode(e); }
-
- //Node addNode() const { return gw.addNode(); }
- //Edge addEdge(const Node& tail, const Node& head) const {
- // return gw.addEdge(tail, head); }
+// //template<typename I> Node aNode(const I& e) const {
+// // return gw.aNode(e); }
+// //template<typename I> Node bNode(const I& e) const {
+// // return gw.bNode(e); }
- //void erase(const OutEdgeIt& e) {
- // first_out_edge(this->tail(e))=e;
- //}
- void erase(const Edge& e) {
- OutEdgeIt f(e);
- next(f);
- first_out_edges.set(this->tail(e), f);
- }
- //template<typename I> void erase(const I& i) const { gw.erase(i); }
+// //Node addNode() const { return gw.addNode(); }
+// //Edge addEdge(const Node& tail, const Node& head) const {
+// // return gw.addEdge(tail, head); }
+
+// //void erase(const OutEdgeIt& e) {
+// // first_out_edge(this->tail(e))=e;
+// //}
+// void erase(const Edge& e) {
+// OutEdgeIt f(e);
+// next(f);
+// first_out_edges.set(this->tail(e), f);
+// }
+// //template<typename I> void erase(const I& i) const { gw.erase(i); }
- //void clear() const { gw.clear(); }
+// //void clear() const { gw.clear(); }
- template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
- public:
- NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
- ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
- NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
- ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
- };
+// template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
+// public:
+// NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
+// ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
+// NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
+// ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
+// };
- template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
- public:
- EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
- ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
- EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
- ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
- };
- };
+// template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
+// public:
+// EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
+// ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
+// EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
+// ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
+// };
+// };
- template<typename GraphWrapper>
- class FilterGraphWrapper {
- };
+// template<typename GraphWrapper>
+// class FilterGraphWrapper {
+// };
- template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
- class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
+// template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+// class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
- //Graph* graph;
+// //Graph* graph;
- public:
- //typedef Graph BaseGraph;
+// public:
+// //typedef Graph BaseGraph;
- typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
- typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
+// typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
+// typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
- typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
- typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
- //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
- //typedef typename Graph::SymEdgeIt SymEdgeIt;
- typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
+// typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
+// typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
+// //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
+// //typedef typename Graph::SymEdgeIt SymEdgeIt;
+// typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
- //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
+// //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
- public:
- FilterGraphWrapper(const Graph& _G, FlowMap& _flow,
- const CapacityMap& _capacity) :
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) {
- }
+// public:
+// FilterGraphWrapper(const Graph& _G, FlowMap& _flow,
+// const CapacityMap& _capacity) :
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) {
+// }
- OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
- while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e))))
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
- return e;
- }
+// OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
+// while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e))))
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+// return e;
+// }
- NodeIt& next(NodeIt& e) const {
- return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
- }
+// NodeIt& next(NodeIt& e) const {
+// return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+// }
- OutEdgeIt& next(OutEdgeIt& e) const {
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
- while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e))))
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
- return e;
- }
+// OutEdgeIt& next(OutEdgeIt& e) const {
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+// while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e))))
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+// return e;
+// }
- NodeIt& first(NodeIt& n) const {
- return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
- }
+// NodeIt& first(NodeIt& n) const {
+// return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
+// }
- void erase(const Edge& e) {
- OutEdgeIt f(e);
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
- while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f))))
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
- first_out_edges.set(this->tail(e), f);
- }
+// void erase(const Edge& e) {
+// OutEdgeIt f(e);
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
+// while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f))))
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
+// first_out_edges.set(this->tail(e), f);
+// }
- //TrivGraphWrapper() : graph(0) { }
- //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
+// //TrivGraphWrapper() : graph(0) { }
+// //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
- //void setGraph(Graph& _graph) { graph = &_graph; }
- //Graph& getGraph() const { return (*graph); }
+// //void setGraph(Graph& _graph) { graph = &_graph; }
+// //Graph& getGraph() const { return (*graph); }
- //template<typename I> I& first(I& i) const { return gw.first(i); }
- //template<typename I, typename P> I& first(I& i, const P& p) const {
- // return gw.first(i, p); }
+// //template<typename I> I& first(I& i) const { return gw.first(i); }
+// //template<typename I, typename P> I& first(I& i, const P& p) const {
+// // return gw.first(i, p); }
- //template<typename I> I getNext(const I& i) const {
- // return gw.getNext(i); }
- //template<typename I> I& next(I &i) const { return gw.next(i); }
+// //template<typename I> I getNext(const I& i) const {
+// // return gw.getNext(i); }
+// //template<typename I> I& next(I &i) const { return gw.next(i); }
- template< typename It > It first() const {
- It e; first(e); return e; }
+// template< typename It > It first() const {
+// It e; first(e); return e; }
- template< typename It > It first(const Node& v) const {
- It e; first(e, v); return e; }
+// template< typename It > It first(const Node& v) const {
+// It e; first(e, v); return e; }
- //Node head(const Edge& e) const { return gw.head(e); }
- //Node tail(const Edge& e) const { return gw.tail(e); }
+// //Node head(const Edge& e) const { return gw.head(e); }
+// //Node tail(const Edge& e) const { return gw.tail(e); }
- //template<typename I> bool valid(const I& i) const
- // { return gw.valid(i); }
+// //template<typename I> bool valid(const I& i) const
+// // { return gw.valid(i); }
- //template<typename I> void setInvalid(const I &i);
- //{ return gw.setInvalid(i); }
+// //template<typename I> void setInvalid(const I &i);
+// //{ return gw.setInvalid(i); }
- //int nodeNum() const { return gw.nodeNum(); }
- //int edgeNum() const { return gw.edgeNum(); }
+// //int nodeNum() const { return gw.nodeNum(); }
+// //int edgeNum() const { return gw.edgeNum(); }
- //template<typename I> Node aNode(const I& e) const {
- // return gw.aNode(e); }
- //template<typename I> Node bNode(const I& e) const {
- // return gw.bNode(e); }
+// //template<typename I> Node aNode(const I& e) const {
+// // return gw.aNode(e); }
+// //template<typename I> Node bNode(const I& e) const {
+// // return gw.bNode(e); }
- //Node addNode() const { return gw.addNode(); }
- //Edge addEdge(const Node& tail, const Node& head) const {
- // return gw.addEdge(tail, head); }
+// //Node addNode() const { return gw.addNode(); }
+// //Edge addEdge(const Node& tail, const Node& head) const {
+// // return gw.addEdge(tail, head); }
- //template<typename I> void erase(const I& i) const { gw.erase(i); }
+// //template<typename I> void erase(const I& i) const { gw.erase(i); }
- //void clear() const { gw.clear(); }
+// //void clear() const { gw.clear(); }
- template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
- public:
- NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
- NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
- };
+// template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
+// public:
+// NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
+// NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
+// };
- template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
- public:
- EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
- EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
- };
+// template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
+// public:
+// EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
+// EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
+// };
- public:
- ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
+// public:
+// ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
- };
+// };
More information about the Lemon-commits
mailing list