1 #ifndef EDMONDS_KARP_HH
2 #define EDMONDS_KARP_HH
8 #include <bfs_iterator.hh>
9 //#include <time_measure.h>
13 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
16 typedef typename Graph::NodeIt NodeIt;
17 typedef typename Graph::EachNodeIt EachNodeIt;
19 typedef typename Graph::SymEdgeIt OldSymEdgeIt;
22 const CapacityMap& capacity;
24 ResGraph(const Graph& _G, FlowMap& _flow,
25 const CapacityMap& _capacity) :
26 G(_G), flow(_flow), capacity(_capacity) { }
31 friend class OutEdgeIt;
34 friend class ResGraph<Graph, Number, FlowMap, CapacityMap>;
36 const ResGraph<Graph, Number, FlowMap, CapacityMap>* resG;
40 //EdgeIt(const EdgeIt& e) : resG(e.resG), sym(e.sym) { }
42 if (resG->G.aNode(sym)==resG->G.tail(sym)) {
43 return (resG->capacity.get(sym)-resG->flow.get(sym));
45 return (resG->flow.get(sym));
48 bool valid() const { return sym.valid(); }
49 void augment(Number a) const {
50 if (resG->G.aNode(sym)==resG->G.tail(sym)) {
51 resG->flow.set(sym, resG->flow.get(sym)+a);
54 resG->flow.set(sym, resG->flow.get(sym)-a);
60 class OutEdgeIt : public EdgeIt {
61 friend class ResGraph<Graph, Number, FlowMap, CapacityMap>;
64 //OutEdgeIt(const OutEdgeIt& e) { resG=e.resG; sym=e.sym; }
66 OutEdgeIt(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _resG, NodeIt v) {
68 sym=resG->G.template first<OldSymEdgeIt>(v);
69 while( sym.valid() && !(free()>0) ) { ++sym; }
72 OutEdgeIt& operator++() {
74 while( sym.valid() && !(free()>0) ) { ++sym; }
79 void getFirst(OutEdgeIt& e, NodeIt v) const {
80 e=OutEdgeIt(*this, v);
82 void getFirst(EachNodeIt& v) const { G.getFirst(v); }
84 template< typename It >
91 template< typename It >
92 It first(NodeIt v) const {
98 NodeIt tail(EdgeIt e) const { return G.aNode(e.sym); }
99 NodeIt head(EdgeIt e) const { return G.bNode(e.sym); }
101 NodeIt aNode(OutEdgeIt e) const { return G.aNode(e.sym); }
102 NodeIt bNode(OutEdgeIt e) const { return G.bNode(e.sym); }
104 int id(NodeIt v) const { return G.id(v); }
106 template <typename S>
108 typename Graph::NodeMap<S> node_map;
110 NodeMap(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
111 NodeMap(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
112 void set(NodeIt nit, S a) { node_map.set(nit, a); }
113 S get(NodeIt nit) const { return node_map.get(nit); }
114 S& operator[](NodeIt nit) { return node_map[nit]; }
115 const S& operator[](NodeIt nit) const { return node_map[nit]; }
121 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
124 typedef typename Graph::NodeIt NodeIt;
125 typedef typename Graph::EachNodeIt EachNodeIt;
127 //typedef typename Graph::SymEdgeIt OldSymEdgeIt;
128 typedef typename Graph::OutEdgeIt OldOutEdgeIt;
129 typedef typename Graph::InEdgeIt OldInEdgeIt;
133 const CapacityMap& capacity;
135 ResGraph2(const Graph& _G, FlowMap& _flow,
136 const CapacityMap& _capacity) :
137 G(_G), flow(_flow), capacity(_capacity) { }
142 friend class OutEdgeIt;
145 friend class ResGraph2<Graph, Number, FlowMap, CapacityMap>;
147 const ResGraph2<Graph, Number, FlowMap, CapacityMap>* resG;
151 bool out_or_in; //1, iff out
153 EdgeIt() : out_or_in(1) { }
154 Number free() const {
156 return (resG->capacity.get(out)-resG->flow.get(out));
158 return (resG->flow.get(in));
162 return out_or_in && out.valid() || in.valid(); }
163 void augment(Number a) const {
165 resG->flow.set(out, resG->flow.get(out)+a);
167 resG->flow.set(in, resG->flow.get(in)-a);
172 class OutEdgeIt : public EdgeIt {
173 friend class ResGraph2<Graph, Number, FlowMap, CapacityMap>;
177 OutEdgeIt(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _resG, NodeIt v) {
179 out=resG->G.template first<OldOutEdgeIt>(v);
180 while( out.valid() && !(free()>0) ) { ++out; }
183 in=resG->G.template first<OldInEdgeIt>(v);
184 while( in.valid() && !(free()>0) ) { ++in; }
188 OutEdgeIt& operator++() {
190 NodeIt v=resG->G.aNode(out);
192 while( out.valid() && !(free()>0) ) { ++out; }
195 in=resG->G.template first<OldInEdgeIt>(v);
196 while( in.valid() && !(free()>0) ) { ++in; }
200 while( in.valid() && !(free()>0) ) { ++in; }
206 void getFirst(OutEdgeIt& e, NodeIt v) const {
207 e=OutEdgeIt(*this, v);
209 void getFirst(EachNodeIt& v) const { G.getFirst(v); }
211 template< typename It >
218 template< typename It >
219 It first(NodeIt v) const {
225 NodeIt tail(EdgeIt e) const {
226 return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
227 NodeIt head(EdgeIt e) const {
228 return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
230 NodeIt aNode(OutEdgeIt e) const {
231 return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
232 NodeIt bNode(OutEdgeIt e) const {
233 return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
235 int id(NodeIt v) const { return G.id(v); }
237 template <typename S>
239 typename Graph::NodeMap<S> node_map;
241 NodeMap(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
242 NodeMap(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
243 void set(NodeIt nit, S a) { node_map.set(nit, a); }
244 S get(NodeIt nit) const { return node_map.get(nit); }
248 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
251 typedef typename Graph::NodeIt NodeIt;
252 typedef typename Graph::EachNodeIt EachNodeIt;
255 //typedef typename Graph::SymEdgeIt OldSymEdgeIt;
256 typedef typename Graph::OutEdgeIt OldOutEdgeIt;
257 typedef typename Graph::InEdgeIt OldInEdgeIt;
260 const CapacityMap& capacity;
262 ResGraph3(const Graph& _G, FlowMap& _flow,
263 const CapacityMap& _capacity) :
264 G(_G), flow(_flow), capacity(_capacity) { }
269 friend class OutEdgeIt;
272 friend class ResGraph3<Graph, Number, FlowMap, CapacityMap>;
274 //const ResGraph3<Graph, Number, FlowMap, CapacityMap>* resG;
277 const CapacityMap* capacity;
281 bool out_or_in; //1, iff out
283 EdgeIt() : out_or_in(1) { }
284 //EdgeIt(const EdgeIt& e) : G(e.G), flow(e.flow), capacity(e.capacity), out(e.out), in(e.in), out_or_in(e.out_or_in) { }
285 Number free() const {
287 return (/*resG->*/capacity->get(out)-/*resG->*/flow->get(out));
289 return (/*resG->*/flow->get(in));
293 return out_or_in && out.valid() || in.valid(); }
294 void augment(Number a) const {
296 /*resG->*/flow->set(out, /*resG->*/flow->get(out)+a);
298 /*resG->*/flow->set(in, /*resG->*/flow->get(in)-a);
305 std::cout << G->id(G->tail(out)) << "--"<< G->id(out) <<"->"<< G->id(G->head(out));
307 std::cout << "invalid";
312 std::cout << G->id(G->head(in)) << "<-"<< G->id(in) <<"--"<< G->id(G->tail(in));
314 std::cout << "invalid";
316 std::cout << std::endl;
320 class OutEdgeIt : public EdgeIt {
321 friend class ResGraph3<Graph, Number, FlowMap, CapacityMap>;
325 OutEdgeIt(const Graph& _G, NodeIt v, FlowMap& _flow, const CapacityMap& _capacity) {
329 //out=/*resG->*/G->template first<OldOutEdgeIt>(v);
331 while( out.valid() && !(free()>0) ) { ++out; }
334 //in=/*resG->*/G->template first<OldInEdgeIt>(v);
336 while( in.valid() && !(free()>0) ) { ++in; }
340 OutEdgeIt& operator++() {
342 NodeIt v=/*resG->*/G->aNode(out);
344 while( out.valid() && !(free()>0) ) { ++out; }
347 G->getFirst(in, v); //=/*resG->*/G->template first<OldInEdgeIt>(v);
348 while( in.valid() && !(free()>0) ) { ++in; }
352 while( in.valid() && !(free()>0) ) { ++in; }
358 class EachEdgeIt : public EdgeIt {
359 typename Graph::EachNodeIt v;
362 //EachEdgeIt(const EachEdgeIt& e) : EdgeIt(e), v(e.v) { }
363 EachEdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) {
369 if (v.valid()) G->getFirst(out, v); else out=OldOutEdgeIt();
370 while (out.valid() && !(free()>0) ) { ++out; }
371 while (v.valid() && !out.valid()) {
373 if (v.valid()) G->getFirst(out, v);
374 while (out.valid() && !(free()>0) ) { ++out; }
379 if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt();
380 while (in.valid() && !(free()>0) ) { ++in; }
381 while (v.valid() && !in.valid()) {
383 if (v.valid()) G->getFirst(in, v);
384 while (in.valid() && !(free()>0) ) { ++in; }
388 EachEdgeIt& operator++() {
391 while (out.valid() && !(free()>0) ) { ++out; }
392 while (v.valid() && !out.valid()) {
394 if (v.valid()) G->getFirst(out, v);
395 while (out.valid() && !(free()>0) ) { ++out; }
400 if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt();
401 while (in.valid() && !(free()>0) ) { ++in; }
402 while (v.valid() && !in.valid()) {
404 if (v.valid()) G->getFirst(in, v);
405 while (in.valid() && !(free()>0) ) { ++in; }
410 while (in.valid() && !(free()>0) ) { ++in; }
411 while (v.valid() && !in.valid()) {
413 if (v.valid()) G->getFirst(in, v);
414 while (in.valid() && !(free()>0) ) { ++in; }
421 void getFirst(OutEdgeIt& e, NodeIt v) const {
422 e=OutEdgeIt(G, v, flow, capacity);
424 void getFirst(EachEdgeIt& e) const {
425 e=EachEdgeIt(G, flow, capacity);
427 void getFirst(EachNodeIt& v) const { G.getFirst(v); }
429 template< typename It >
436 template< typename It >
437 It first(NodeIt v) const {
443 NodeIt tail(EdgeIt e) const {
444 return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
445 NodeIt head(EdgeIt e) const {
446 return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
448 NodeIt aNode(OutEdgeIt e) const {
449 return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
450 NodeIt bNode(OutEdgeIt e) const {
451 return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
453 int id(NodeIt v) const { return G.id(v); }
455 template <typename T>
457 typename Graph::NodeMap<T> node_map;
459 NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
460 NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(_G.G, a) { }
461 void set(NodeIt nit, T a) { node_map.set(nit, a); }
462 T get(NodeIt nit) const { return node_map.get(nit); }
465 template <typename T>
467 typename Graph::EdgeMap<T> forward_map, backward_map;
469 EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.G), backward_map(_G.G) { }
470 EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.G, a), backward_map(_G.G, a) { }
471 void set(EdgeIt e, T a) {
473 forward_map.set(e.out, a);
475 backward_map.set(e.in, a);
479 return forward_map.get(e.out);
481 return backward_map.get(e.in);
487 template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
490 typedef typename Graph::NodeIt NodeIt;
491 typedef typename Graph::EdgeIt EdgeIt;
492 typedef typename Graph::EachEdgeIt EachEdgeIt;
493 typedef typename Graph::OutEdgeIt OutEdgeIt;
494 typedef typename Graph::InEdgeIt InEdgeIt;
501 const CapacityMap& capacity;
502 typedef ResGraph3<Graph, Number, FlowMap, CapacityMap > AugGraph;
503 typedef typename AugGraph::OutEdgeIt AugOutEdgeIt;
504 typedef typename AugGraph::EdgeIt AugEdgeIt;
506 //AugGraph res_graph;
507 //typedef typename AugGraph::NodeMap<bool> ReachedMap;
508 //typename AugGraph::NodeMap<AugEdgeIt> pred;
509 //typename AugGraph::NodeMap<Number> free;
511 MaxFlow(const Graph& _G, NodeIt _s, NodeIt _t, FlowMap& _flow, const CapacityMap& _capacity) :
512 G(_G), s(_s), t(_t), flow(_flow), capacity(_capacity) //,
513 //res_graph(G, flow, capacity), pred(res_graph), free(res_graph)
515 bool augmentOnShortestPath() {
516 AugGraph res_graph(G, flow, capacity);
519 typedef typename AugGraph::NodeMap<bool> ReachedMap;
520 BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph);
521 res_bfs.pushAndSetReached(s);
523 typename AugGraph::NodeMap<AugEdgeIt> pred(res_graph);
524 //filled up with invalid iterators
525 //pred.set(s, AugEdgeIt());
527 typename AugGraph::NodeMap<Number> free(res_graph);
529 //searching for augmenting path
530 while ( !res_bfs.finished() ) {
531 AugOutEdgeIt e=AugOutEdgeIt(res_bfs);
532 if (e.valid() && res_bfs.isBNodeNewlyReached()) {
533 NodeIt v=res_graph.tail(e);
534 NodeIt w=res_graph.head(e);
536 if (pred.get(v).valid()) {
537 free.set(w, std::min(free.get(v), e.free()));
539 free.set(w, e.free());
541 if (res_graph.head(e)==t) { _augment=true; break; }
545 } //end of searching augmenting path
549 Number augment_value=free.get(t);
550 while (pred.get(n).valid()) {
551 AugEdgeIt e=pred.get(n);
552 e.augment(augment_value);
559 template<typename MutableGraph> bool augmentOnBlockingFlow() {
562 AugGraph res_graph(G, flow, capacity);
564 typedef typename AugGraph::NodeMap<bool> ReachedMap;
565 BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > bfs(res_graph);
567 bfs.pushAndSetReached(s);
568 typename AugGraph::NodeMap<int> dist(res_graph); //filled up with 0's
569 while ( !bfs.finished() ) {
570 AugOutEdgeIt e=AugOutEdgeIt(bfs);
571 if (e.valid() && bfs.isBNodeNewlyReached()) {
572 dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
576 } //computing distances from s in the residual graph
579 typename AugGraph::NodeMap<NodeIt> res_graph_to_F(res_graph);
580 for(typename AugGraph::EachNodeIt n=res_graph.template first<typename AugGraph::EachNodeIt>(); n.valid(); ++n) {
581 res_graph_to_F.set(n, F.addNode());
584 typename MutableGraph::NodeIt sF=res_graph_to_F.get(s);
585 typename MutableGraph::NodeIt tF=res_graph_to_F.get(t);
587 typename MutableGraph::EdgeMap<AugEdgeIt> original_edge(F);
588 typename MutableGraph::EdgeMap<Number> free_on_edge(F);
590 //Making F to the graph containing the edges of the residual graph
591 //which are in some shortest paths
592 for(typename AugGraph::EachEdgeIt e=res_graph.template first<typename AugGraph::EachEdgeIt>(); e.valid(); ++e) {
593 if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
594 typename MutableGraph::EdgeIt f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
595 original_edge.update();
596 original_edge.set(f, e);
597 free_on_edge.update();
598 free_on_edge.set(f, e.free());
606 //computing blocking flow with dfs
607 typedef typename MutableGraph::NodeMap<bool> BlockingReachedMap;
608 DfsIterator4< MutableGraph, typename MutableGraph::OutEdgeIt, BlockingReachedMap > dfs(F);
609 typename MutableGraph::NodeMap<EdgeIt> pred(F); //invalid iterators
610 typename MutableGraph::NodeMap<Number> free(F);
612 dfs.pushAndSetReached(sF);
613 while (!dfs.finished()) {
615 if (typename MutableGraph::OutEdgeIt(dfs).valid()) {
616 //std::cout << "OutEdgeIt: " << dfs;
617 //std::cout << " aNode: " << F.aNode(dfs);
618 //std::cout << " bNode: " << F.bNode(dfs) << " ";
620 typename MutableGraph::NodeIt v=F.aNode(dfs);
621 typename MutableGraph::NodeIt w=F.bNode(dfs);
623 if (pred.get(v).valid()) {
624 free.set(w, std::min(free.get(v), free_on_edge.get(dfs)));
626 free.set(w, free_on_edge.get(dfs)/*original_edge.get(dfs).free()*/);
629 //std::cout << "AUGMENTATION"<<std::endl;
635 //std::cout << "OutEdgeIt: " << "invalid";
636 //std::cout << " aNode: " << dfs.aNode();
637 //std::cout << " bNode: " << "invalid" << " ";
639 if (dfs.isBNodeNewlyReached()) {
640 //std::cout << "bNodeIsNewlyReached ";
642 //std::cout << "bNodeIsNotNewlyReached ";
643 if (typename MutableGraph::OutEdgeIt(dfs).valid()) {
644 //std::cout << "DELETE ";
645 F.erase(typename MutableGraph::OutEdgeIt(dfs));
648 //if (dfs.isANodeExamined()) {
649 //std::cout << "aNodeIsExamined ";
651 //std::cout << "aNodeIsNotExamined ";
653 //std::cout<<std::endl;
657 typename MutableGraph::NodeIt n=tF;
658 Number augment_value=free.get(tF);
659 while (pred.get(n).valid()) {
660 typename MutableGraph::EdgeIt e=pred.get(n);
661 original_edge.get(e).augment(augment_value);
663 if (free_on_edge.get(e)==augment_value)
666 free_on_edge.set(e, free_on_edge.get(e)-augment_value);
675 //int num_of_augmentations=0;
676 while (augmentOnShortestPath()) {
677 //while (augmentOnBlockingFlow<MutableGraph>()) {
678 //std::cout << ++num_of_augmentations << " ";
679 //std::cout<<std::endl;
682 template<typename MutableGraph> void run() {
683 //int num_of_augmentations=0;
684 //while (augmentOnShortestPath()) {
685 while (augmentOnBlockingFlow<MutableGraph>()) {
686 //std::cout << ++num_of_augmentations << " ";
687 //std::cout<<std::endl;
692 for(OutEdgeIt i=G.template first<OutEdgeIt>(s); i.valid(); ++i) {
701 template <typename Graph>
702 class IteratorBoolNodeMap {
703 typedef typename Graph::NodeIt NodeIt;
704 typedef typename Graph::EachNodeIt EachNodeIt;
710 BoolItem() : value(false), prev(), next() {}
717 typename Graph::NodeMap<BoolItem> container;
719 typedef bool ValueType;
720 typedef NodeIt KeyType;
721 IteratorBoolNodeMap(const Graph& _G) : G(_G), container(G), first_true(NodeIt()) {
722 //for (EachNodeIt e=G.template first<EacNodeIt>(); e.valid(); ++e) {
723 //BoolItem b=container.get(e);
727 G.getFirst(first_false);
729 for (EachNodeIt e=G.template first<EacNodeIt>(); e.valid(); ++e) {
730 container[e].prev=e_prev;
731 if (e_prev.valid()) container[e_prev].next=e;
735 //NodeMap(const Graph& _G, T a) :
736 // G(_G), container(G.node_id, a) { }
738 void set(NodeIt nit, T a) { container[G.id(nit)]=a; }
739 T get(NodeIt nit) const { return container[G.id(nit)]; }
740 //void update() { container.resize(G.node_id); }
741 //void update(T a) { container.resize(G.node_id, a); }
746 template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
749 typedef typename Graph::NodeIt NodeIt;
750 typedef typename Graph::EdgeIt EdgeIt;
751 typedef typename Graph::EachEdgeIt EachEdgeIt;
752 typedef typename Graph::OutEdgeIt OutEdgeIt;
753 typedef typename Graph::InEdgeIt InEdgeIt;
756 std::list<NodeIt>& S;
757 std::list<NodeIt>& T;
759 const CapacityMap& capacity;
760 typedef ResGraph<Graph, Number, FlowMap, CapacityMap > AugGraph;
761 typedef typename AugGraph::OutEdgeIt AugOutEdgeIt;
762 typedef typename AugGraph::EdgeIt AugEdgeIt;
763 typename Graph::NodeMap<bool> SMap;
764 typename Graph::NodeMap<bool> TMap;
766 MaxFlow2(const Graph& _G, std::list<NodeIt>& _S, std::list<NodeIt>& _T, FlowMap& _flow, const CapacityMap& _capacity) : G(_G), S(_S), T(_T), flow(_flow), capacity(_capacity), SMap(_G), TMap(_G) {
767 for(typename std::list<NodeIt>::const_iterator i=S.begin();
771 for (typename std::list<NodeIt>::const_iterator i=T.begin();
777 AugGraph res_graph(G, flow, capacity);
779 NodeIt reached_t_node;
781 typedef typename AugGraph::NodeMap<bool> ReachedMap;
782 BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph);
783 for(typename std::list<NodeIt>::const_iterator i=S.begin();
785 res_bfs.pushAndSetReached(*i);
787 //res_bfs.pushAndSetReached(s);
789 typename AugGraph::NodeMap<AugEdgeIt> pred(res_graph);
790 //filled up with invalid iterators
792 typename AugGraph::NodeMap<Number> free(res_graph);
794 //searching for augmenting path
795 while ( !res_bfs.finished() ) {
796 AugOutEdgeIt e=AugOutEdgeIt(res_bfs);
797 if (e.valid() && res_bfs.isBNodeNewlyReached()) {
798 NodeIt v=res_graph.tail(e);
799 NodeIt w=res_graph.head(e);
801 if (pred.get(v).valid()) {
802 free.set(w, std::min(free.get(v), e.free()));
804 free.set(w, e.free());
806 if (TMap.get(res_graph.head(e))) {
808 reached_t_node=res_graph.head(e);
814 } //end of searching augmenting path
817 NodeIt n=reached_t_node;
818 Number augment_value=free.get(reached_t_node);
819 while (pred.get(n).valid()) {
820 AugEdgeIt e=pred.get(n);
821 e.augment(augment_value);
829 while (augment()) { }
833 for(typename std::list<NodeIt>::const_iterator i=S.begin();
835 for(OutEdgeIt e=G.template first<OutEdgeIt>(*i); e.valid(); ++e) {
838 for(InEdgeIt e=G.template first<InEdgeIt>(*i); e.valid(); ++e) {
850 #endif //EDMONDS_KARP_HH