7 list 'level_list' on the nodes on level i implemented by hand
8 stack 'active' on the active nodes on level i
9 runs heuristic 'highest label' for H1*n relabels
10 runs heuristic 'bound decrease' for H0*n relabels, starts with 'highest label'
12 Parameters H0 and H1 are initialized to 20 and 1.
16 Preflow(Graph, Node, Node, CapMap, FlowMap, bool) : bool must be false if
17 FlowMap is not constant zero, and should be true if it is
23 Num flowValue() : returns the value of a maximum flow
25 void minMinCut(CutMap& M) : sets M to the characteristic vector of the
26 minimum min cut. M should be a map of bools initialized to false. ??Is it OK?
28 void maxMinCut(CutMap& M) : sets M to the characteristic vector of the
29 maximum min cut. M should be a map of bools initialized to false.
31 void minCut(CutMap& M) : sets M to the characteristic vector of
32 a min cut. M should be a map of bools initialized to false.
36 #ifndef HUGO_MAX_FLOW_H
37 #define HUGO_MAX_FLOW_H
43 #include <hugo/graph_wrapper.h>
45 #include <hugo/invalid.h>
46 #include <hugo/maps.h>
47 #include <for_each_macros.h>
50 /// \brief Maximum flows.
56 // ///\author Marton Makai, Jacint Szabo
57 /// A class for computing max flows and related quantities.
59 template <typename Graph, typename Num,
60 typename CapMap=typename Graph::template EdgeMap<Num>,
61 typename FlowMap=typename Graph::template EdgeMap<Num> >
64 typedef typename Graph::Node Node;
65 typedef typename Graph::NodeIt NodeIt;
66 typedef typename Graph::OutEdgeIt OutEdgeIt;
67 typedef typename Graph::InEdgeIt InEdgeIt;
69 typedef typename std::vector<std::stack<Node> > VecStack;
70 typedef typename Graph::template NodeMap<Node> NNMap;
71 typedef typename std::vector<Node> VecNode;
76 const CapMap* capacity;
78 int n; //the number of nodes of G
79 typedef ResGraphWrapper<const Graph, Num, CapMap, FlowMap> ResGW;
80 typedef typename ResGW::OutEdgeIt ResGWOutEdgeIt;
81 typedef typename ResGW::Edge ResGWEdge;
82 //typedef typename ResGW::template NodeMap<bool> ReachedMap;
83 typedef typename Graph::template NodeMap<int> ReachedMap;
85 //level works as a bool map in augmenting path algorithms
86 //and is used by bfs for storing reached information.
87 //In preflow, it shows levels of nodes.
88 //typename Graph::template NodeMap<int> level;
89 typename Graph::template NodeMap<Num> excess;
92 // void set(const Graph& _G, Node _s, Node _t, const CapMap& _capacity,
98 // capacity=&_capacity;
101 // level.set (_G); //kellene vmi ilyesmi fv
102 // excess(_G,0); //itt is
105 // constants used for heuristics
106 static const int H0=20;
107 static const int H1=1;
111 ///\todo Document this.
112 ///\todo Maybe, it should be PRE_FLOW instead.
113 ///- \c NO_FLOW means nothing,
114 ///- \c ZERO_FLOW means something,
115 ///- \c GEN_FLOW means something else,
116 ///- \c PRE_FLOW is something different.
124 MaxFlow(const Graph& _G, Node _s, Node _t, const CapMap& _capacity,
126 g(&_G), s(_s), t(_t), capacity(&_capacity),
127 flow(&_flow), n(_G.nodeNum()), level(_G), excess(_G,0) {}
129 /// A max flow algorithm is run.
130 /// \pre The flow have to satisfy the requirements
132 void run(flowEnum fe=ZERO_FLOW) {
136 /// A preflow algorithm is run.
137 /// \pre The initial edge-map have to be a
138 /// zero flow if \c fe is \c ZERO_FLOW,
139 /// a flow if \c fe is \c GEN_FLOW,
140 /// a pre-flow if fe is \c PRE_FLOW and
141 /// anything if fe is NO_FLOW.
142 void preflow(flowEnum fe) {
147 /// Run the first phase of preflow, starting from a 0 flow, from a flow,
148 /// or from a preflow, of from undefined value according to \c fe.
149 void preflowPhase0(flowEnum fe);
151 /// Second phase of preflow.
152 void preflowPhase1();
154 /// Starting from a flow, this method searches for an augmenting path
155 /// according to the Edmonds-Karp algorithm
156 /// and augments the flow on if any.
157 /// The return value shows if the augmentation was succesful.
158 bool augmentOnShortestPath();
160 /// Starting from a flow, this method searches for an augmenting blocking
161 /// flow according to Dinits' algorithm and augments the flow on if any.
162 /// The blocking flow is computed in a physically constructed
163 /// residual graph of type \c Mutablegraph.
164 /// The return value show sif the augmentation was succesful.
165 template<typename MutableGraph> bool augmentOnBlockingFlow();
167 /// The same as \c augmentOnBlockingFlow<MutableGraph> but the
168 /// residual graph is not constructed physically.
169 /// The return value shows if the augmentation was succesful.
170 bool augmentOnBlockingFlow2();
172 /// Returns the actual flow value.
173 /// More precisely, it returns the negative excess of s, thus
174 /// this works also for preflows.
177 FOR_EACH_INC_LOC(InEdgeIt, e, *g, t) a+=(*flow)[e];
178 FOR_EACH_INC_LOC(OutEdgeIt, e, *g, t) a-=(*flow)[e];
182 /// Should be used between preflowPhase0 and preflowPhase1.
183 /// \todo We have to make some status variable which shows the
185 /// of the class. This enables us to determine which methods are valid
186 /// for MinCut computation
187 template<typename _CutMap>
188 void actMinCut(_CutMap& M) {
190 for(g->first(v); g->valid(v); g->next(v)) {
191 if ( level[v] < n ) {
199 /// The unique inclusionwise minimum cut is computed by
200 /// processing a bfs from s in the residual graph.
201 /// \pre flow have to be a max flow otherwise it will the whole node-set.
202 template<typename _CutMap>
203 void minMinCut(_CutMap& M) {
205 std::queue<Node> queue;
210 while (!queue.empty()) {
211 Node w=queue.front();
215 for(g->first(e,w) ; g->valid(e); g->next(e)) {
217 if (!M[v] && (*flow)[e] < (*capacity)[e] ) {
224 for(g->first(f,w) ; g->valid(f); g->next(f)) {
226 if (!M[v] && (*flow)[f] > 0 ) {
235 /// The unique inclusionwise maximum cut is computed by
236 /// processing a reverse bfs from t in the residual graph.
237 /// \pre flow have to be a max flow otherwise it will be empty.
238 template<typename _CutMap>
239 void maxMinCut(_CutMap& M) {
242 for(g->first(v) ; g->valid(v); g->next(v)) {
246 std::queue<Node> queue;
251 while (!queue.empty()) {
252 Node w=queue.front();
256 for(g->first(e,w) ; g->valid(e); g->next(e)) {
258 if (M[v] && (*flow)[e] < (*capacity)[e] ) {
265 for(g->first(f,w) ; g->valid(f); g->next(f)) {
267 if (M[v] && (*flow)[f] > 0 ) {
276 /// A minimum cut is computed.
277 template<typename CutMap>
278 void minCut(CutMap& M) { minMinCut(M); }
281 void resetSource(Node _s) { s=_s; }
283 void resetTarget(Node _t) { t=_t; }
285 /// capacity-map is changed.
286 void resetCap(const CapMap& _cap) { capacity=&_cap; }
288 /// flow-map is changed.
289 void resetFlow(FlowMap& _flow) { flow=&_flow; }
294 int push(Node w, VecStack& active) {
298 int newlevel=n; //bound on the next level of w
301 for(g->first(e,w); g->valid(e); g->next(e)) {
303 if ( (*flow)[e] >= (*capacity)[e] ) continue;
306 if( lev > level[v] ) { //Push is allowed now
308 if ( excess[v]<=0 && v!=t && v!=s ) {
310 active[lev_v].push(v);
313 Num cap=(*capacity)[e];
317 if ( remcap >= exc ) { //A nonsaturating push.
319 flow->set(e, flo+exc);
320 excess.set(v, excess[v]+exc);
324 } else { //A saturating push.
326 excess.set(v, excess[v]+remcap);
329 } else if ( newlevel > level[v] ) newlevel = level[v];
334 for(g->first(e,w); g->valid(e); g->next(e)) {
336 if( (*flow)[e] <= 0 ) continue;
339 if( lev > level[v] ) { //Push is allowed now
341 if ( excess[v]<=0 && v!=t && v!=s ) {
343 active[lev_v].push(v);
348 if ( flo >= exc ) { //A nonsaturating push.
350 flow->set(e, flo-exc);
351 excess.set(v, excess[v]+exc);
354 } else { //A saturating push.
356 excess.set(v, excess[v]+flo);
360 } else if ( newlevel > level[v] ) newlevel = level[v];
363 } // if w still has excess after the out edge for cycle
371 void preflowPreproc(flowEnum fe, VecStack& active,
372 VecNode& level_list, NNMap& left, NNMap& right)
374 std::queue<Node> bfs_queue;
379 //Reverse_bfs from t, to find the starting level.
383 while (!bfs_queue.empty()) {
385 Node v=bfs_queue.front();
390 for(g->first(e,v); g->valid(e); g->next(e)) {
392 if ( level[w] == n && w != s ) {
394 Node first=level_list[l];
395 if ( g->valid(first) ) left.set(first,w);
405 for(g->first(e,s); g->valid(e); g->next(e))
407 Num c=(*capacity)[e];
408 if ( c <= 0 ) continue;
410 if ( level[w] < n ) {
411 if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
413 excess.set(w, excess[w]+c);
422 //Reverse_bfs from t in the residual graph,
423 //to find the starting level.
427 while (!bfs_queue.empty()) {
429 Node v=bfs_queue.front();
434 for(g->first(e,v); g->valid(e); g->next(e)) {
435 if ( (*capacity)[e] <= (*flow)[e] ) continue;
437 if ( level[w] == n && w != s ) {
439 Node first=level_list[l];
440 if ( g->valid(first) ) left.set(first,w);
448 for(g->first(f,v); g->valid(f); g->next(f)) {
449 if ( 0 >= (*flow)[f] ) continue;
451 if ( level[w] == n && w != s ) {
453 Node first=level_list[l];
454 if ( g->valid(first) ) left.set(first,w);
465 for(g->first(e,s); g->valid(e); g->next(e))
467 Num rem=(*capacity)[e]-(*flow)[e];
468 if ( rem <= 0 ) continue;
470 if ( level[w] < n ) {
471 if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
472 flow->set(e, (*capacity)[e]);
473 excess.set(w, excess[w]+rem);
478 for(g->first(f,s); g->valid(f); g->next(f))
480 if ( (*flow)[f] <= 0 ) continue;
482 if ( level[w] < n ) {
483 if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
484 excess.set(w, excess[w]+(*flow)[f]);
495 void relabel(Node w, int newlevel, VecStack& active,
496 VecNode& level_list, NNMap& left,
497 NNMap& right, int& b, int& k, bool what_heur )
502 Node right_n=right[w];
506 if ( g->valid(right_n) ) {
507 if ( g->valid(left_n) ) {
508 right.set(left_n, right_n);
509 left.set(right_n, left_n);
511 level_list[lev]=right_n;
512 left.set(right_n, INVALID);
515 if ( g->valid(left_n) ) {
516 right.set(left_n, INVALID);
518 level_list[lev]=INVALID;
523 if ( !g->valid(level_list[lev]) ) {
526 for (int i=lev; i!=k ; ) {
527 Node v=level_list[++i];
528 while ( g->valid(v) ) {
532 level_list[i]=INVALID;
534 while ( !active[i].empty() ) {
535 active[i].pop(); //FIXME: ezt szebben kene
547 if ( newlevel == n ) level.set(w,n);
549 level.set(w,++newlevel);
550 active[newlevel].push(w);
551 if ( what_heur ) b=newlevel;
552 if ( k < newlevel ) ++k; //now k=newlevel
553 Node first=level_list[newlevel];
554 if ( g->valid(first) ) left.set(first,w);
557 level_list[newlevel]=w;
564 template<typename MapGraphWrapper>
567 const MapGraphWrapper* g;
568 typename MapGraphWrapper::template NodeMap<int> dist;
570 DistanceMap(MapGraphWrapper& _g) : g(&_g), dist(*g, g->nodeNum()) { }
571 void set(const typename MapGraphWrapper::Node& n, int a) {
574 int operator[](const typename MapGraphWrapper::Node& n)
576 // int get(const typename MapGraphWrapper::Node& n) const {
578 // bool get(const typename MapGraphWrapper::Edge& e) const {
579 // return (dist.get(g->tail(e))<dist.get(g->head(e))); }
580 bool operator[](const typename MapGraphWrapper::Edge& e) const {
581 return (dist[g->tail(e)]<dist[g->head(e)]);
588 template <typename Graph, typename Num, typename CapMap, typename FlowMap>
589 void MaxFlow<Graph, Num, CapMap, FlowMap>::preflowPhase0( flowEnum fe )
592 int heur0=(int)(H0*n); //time while running 'bound decrease'
593 int heur1=(int)(H1*n); //time while running 'highest label'
594 int heur=heur1; //starting time interval (#of relabels)
598 //It is 0 in case 'bound decrease' and 1 in case 'highest label'
601 //Needed for 'bound decrease', true means no active nodes are above bound
604 int k=n-2; //bound on the highest level under n containing a node
605 int b=k; //bound on the highest level under n of an active node
609 NNMap left(*g, INVALID);
610 NNMap right(*g, INVALID);
611 VecNode level_list(n,INVALID);
612 //List of the nodes in level i<n, set to n.
615 for(g->first(v); g->valid(v); g->next(v)) level.set(v,n);
616 //setting each node to level n
621 //computing the excess
623 for(g->first(v); g->valid(v); g->next(v)) {
627 for(g->first(e,v); g->valid(e); g->next(e)) exc+=(*flow)[e];
629 for(g->first(f,v); g->valid(f); g->next(f)) exc-=(*flow)[f];
633 //putting the active nodes into the stack
635 if ( exc > 0 && lev < n && v != t ) active[lev].push(v);
641 //computing the excess of t
645 for(g->first(e,t); g->valid(e); g->next(e)) exc+=(*flow)[e];
647 for(g->first(f,t); g->valid(f); g->next(f)) exc-=(*flow)[f];
656 preflowPreproc(fe, active, level_list, left, right);
657 //End of preprocessing
660 //Push/relabel on the highest level active nodes.
663 if ( !what_heur && !end && k > 0 ) {
669 if ( active[b].empty() ) --b;
672 Node w=active[b].top();
674 int newlevel=push(w,active);
675 if ( excess[w] > 0 ) relabel(w, newlevel, active, level_list,
676 left, right, b, k, what_heur);
679 if ( numrelabel >= heur ) {
697 template <typename Graph, typename Num, typename CapMap, typename FlowMap>
698 void MaxFlow<Graph, Num, CapMap, FlowMap>::preflowPhase1()
701 int k=n-2; //bound on the highest level under n containing a node
702 int b=k; //bound on the highest level under n of an active node
706 std::queue<Node> bfs_queue;
709 while (!bfs_queue.empty()) {
711 Node v=bfs_queue.front();
716 for(g->first(e,v); g->valid(e); g->next(e)) {
717 if ( (*capacity)[e] <= (*flow)[e] ) continue;
719 if ( level[u] >= n ) {
722 if ( excess[u] > 0 ) active[l].push(u);
727 for(g->first(f,v); g->valid(f); g->next(f)) {
728 if ( 0 >= (*flow)[f] ) continue;
730 if ( level[u] >= n ) {
733 if ( excess[u] > 0 ) active[l].push(u);
743 if ( active[b].empty() ) --b;
745 Node w=active[b].top();
747 int newlevel=push(w,active);
750 if ( excess[w] > 0 ) {
751 level.set(w,++newlevel);
752 active[newlevel].push(w);
755 } // if stack[b] is nonempty
761 template <typename Graph, typename Num, typename CapMap, typename FlowMap>
762 bool MaxFlow<Graph, Num, CapMap, FlowMap>::augmentOnShortestPath()
764 ResGW res_graph(*g, *capacity, *flow);
767 //ReachedMap level(res_graph);
768 FOR_EACH_LOC(typename Graph::NodeIt, e, *g) level.set(e, 0);
769 BfsIterator<ResGW, ReachedMap> bfs(res_graph, level);
770 bfs.pushAndSetReached(s);
772 typename ResGW::template NodeMap<ResGWEdge> pred(res_graph);
773 pred.set(s, INVALID);
775 typename ResGW::template NodeMap<Num> free(res_graph);
777 //searching for augmenting path
778 while ( !bfs.finished() ) {
779 ResGWOutEdgeIt e=bfs;
780 if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
781 Node v=res_graph.tail(e);
782 Node w=res_graph.head(e);
784 if (res_graph.valid(pred[v])) {
785 free.set(w, std::min(free[v], res_graph.resCap(e)));
787 free.set(w, res_graph.resCap(e));
789 if (res_graph.head(e)==t) { _augment=true; break; }
793 } //end of searching augmenting path
797 Num augment_value=free[t];
798 while (res_graph.valid(pred[n])) {
800 res_graph.augment(e, augment_value);
814 template <typename Graph, typename Num, typename CapMap, typename FlowMap>
815 template<typename MutableGraph>
816 bool MaxFlow<Graph, Num, CapMap, FlowMap>::augmentOnBlockingFlow()
818 typedef MutableGraph MG;
821 ResGW res_graph(*g, *capacity, *flow);
823 //bfs for distances on the residual graph
824 //ReachedMap level(res_graph);
825 FOR_EACH_LOC(typename Graph::NodeIt, e, *g) level.set(e, 0);
826 BfsIterator<ResGW, ReachedMap> bfs(res_graph, level);
827 bfs.pushAndSetReached(s);
828 typename ResGW::template NodeMap<int>
829 dist(res_graph); //filled up with 0's
831 //F will contain the physical copy of the residual graph
832 //with the set of edges which are on shortest paths
834 typename ResGW::template NodeMap<typename MG::Node>
835 res_graph_to_F(res_graph);
837 typename ResGW::NodeIt n;
838 for(res_graph.first(n); res_graph.valid(n); res_graph.next(n)) {
839 res_graph_to_F.set(n, F.addNode());
843 typename MG::Node sF=res_graph_to_F[s];
844 typename MG::Node tF=res_graph_to_F[t];
845 typename MG::template EdgeMap<ResGWEdge> original_edge(F);
846 typename MG::template EdgeMap<Num> residual_capacity(F);
848 while ( !bfs.finished() ) {
849 ResGWOutEdgeIt e=bfs;
850 if (res_graph.valid(e)) {
851 if (bfs.isBNodeNewlyReached()) {
852 dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
853 typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)],
854 res_graph_to_F[res_graph.head(e)]);
855 original_edge.update();
856 original_edge.set(f, e);
857 residual_capacity.update();
858 residual_capacity.set(f, res_graph.resCap(e));
860 if (dist[res_graph.head(e)]==(dist[res_graph.tail(e)]+1)) {
861 typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)],
862 res_graph_to_F[res_graph.head(e)]);
863 original_edge.update();
864 original_edge.set(f, e);
865 residual_capacity.update();
866 residual_capacity.set(f, res_graph.resCap(e));
871 } //computing distances from s in the residual graph
877 //computing blocking flow with dfs
878 DfsIterator< MG, typename MG::template NodeMap<bool> > dfs(F);
879 typename MG::template NodeMap<typename MG::Edge> pred(F);
880 pred.set(sF, INVALID);
881 //invalid iterators for sources
883 typename MG::template NodeMap<Num> free(F);
885 dfs.pushAndSetReached(sF);
886 while (!dfs.finished()) {
888 if (F.valid(/*typename MG::OutEdgeIt*/(dfs))) {
889 if (dfs.isBNodeNewlyReached()) {
890 typename MG::Node v=F.aNode(dfs);
891 typename MG::Node w=F.bNode(dfs);
893 if (F.valid(pred[v])) {
894 free.set(w, std::min(free[v], residual_capacity[dfs]));
896 free.set(w, residual_capacity[dfs]);
905 F.erase(/*typename MG::OutEdgeIt*/(dfs));
911 typename MG::Node n=tF;
912 Num augment_value=free[tF];
913 while (F.valid(pred[n])) {
914 typename MG::Edge e=pred[n];
915 res_graph.augment(original_edge[e], augment_value);
917 if (residual_capacity[e]==augment_value)
920 residual_capacity.set(e, residual_capacity[e]-augment_value);
932 template <typename Graph, typename Num, typename CapMap, typename FlowMap>
933 bool MaxFlow<Graph, Num, CapMap, FlowMap>::augmentOnBlockingFlow2()
937 ResGW res_graph(*g, *capacity, *flow);
939 //ReachedMap level(res_graph);
940 FOR_EACH_LOC(typename Graph::NodeIt, e, *g) level.set(e, 0);
941 BfsIterator<ResGW, ReachedMap> bfs(res_graph, level);
943 bfs.pushAndSetReached(s);
944 DistanceMap<ResGW> dist(res_graph);
945 while ( !bfs.finished() ) {
946 ResGWOutEdgeIt e=bfs;
947 if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
948 dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
951 } //computing distances from s in the residual graph
953 //Subgraph containing the edges on some shortest paths
954 ConstMap<typename ResGW::Node, bool> true_map(true);
955 typedef SubGraphWrapper<ResGW, ConstMap<typename ResGW::Node, bool>,
956 DistanceMap<ResGW> > FilterResGW;
957 FilterResGW filter_res_graph(res_graph, true_map, dist);
959 //Subgraph, which is able to delete edges which are already
961 typename FilterResGW::template NodeMap<typename FilterResGW::OutEdgeIt>
962 first_out_edges(filter_res_graph);
963 typename FilterResGW::NodeIt v;
964 for(filter_res_graph.first(v); filter_res_graph.valid(v);
965 filter_res_graph.next(v))
967 typename FilterResGW::OutEdgeIt e;
968 filter_res_graph.first(e, v);
969 first_out_edges.set(v, e);
971 typedef ErasingFirstGraphWrapper<FilterResGW, typename FilterResGW::
972 template NodeMap<typename FilterResGW::OutEdgeIt> > ErasingResGW;
973 ErasingResGW erasing_res_graph(filter_res_graph, first_out_edges);
980 //computing blocking flow with dfs
981 DfsIterator< ErasingResGW,
982 typename ErasingResGW::template NodeMap<bool> >
983 dfs(erasing_res_graph);
984 typename ErasingResGW::
985 template NodeMap<typename ErasingResGW::OutEdgeIt>
986 pred(erasing_res_graph);
987 pred.set(s, INVALID);
988 //invalid iterators for sources
990 typename ErasingResGW::template NodeMap<Num>
991 free1(erasing_res_graph);
993 dfs.pushAndSetReached
995 (typename ErasingResGW::Node
996 (typename FilterResGW::Node
997 (typename ResGW::Node(s)
1001 while (!dfs.finished()) {
1003 if (erasing_res_graph.valid(typename ErasingResGW::OutEdgeIt(dfs)))
1005 if (dfs.isBNodeNewlyReached()) {
1007 typename ErasingResGW::Node v=erasing_res_graph.aNode(dfs);
1008 typename ErasingResGW::Node w=erasing_res_graph.bNode(dfs);
1010 pred.set(w, /*typename ErasingResGW::OutEdgeIt*/(dfs));
1011 if (erasing_res_graph.valid(pred[v])) {
1013 (w, std::min(free1[v], res_graph.resCap
1014 (typename ErasingResGW::OutEdgeIt(dfs))));
1017 (w, res_graph.resCap
1018 (typename ErasingResGW::OutEdgeIt(dfs)));
1027 erasing_res_graph.erase(dfs);
1033 typename ErasingResGW::Node
1034 n=typename FilterResGW::Node(typename ResGW::Node(t));
1035 // typename ResGW::NodeMap<Num> a(res_graph);
1036 // typename ResGW::Node b;
1038 // typename FilterResGW::NodeMap<Num> a1(filter_res_graph);
1039 // typename FilterResGW::Node b1;
1041 // typename ErasingResGW::NodeMap<Num> a2(erasing_res_graph);
1042 // typename ErasingResGW::Node b2;
1044 Num augment_value=free1[n];
1045 while (erasing_res_graph.valid(pred[n])) {
1046 typename ErasingResGW::OutEdgeIt e=pred[n];
1047 res_graph.augment(e, augment_value);
1048 n=erasing_res_graph.tail(e);
1049 if (res_graph.resCap(e)==0)
1050 erasing_res_graph.erase(e);
1054 } //while (__augment)
1062 #endif //HUGO_MAX_FLOW_H