# HG changeset patch # User marci # Date 1078324238 0 # Node ID 004fdf703abba8628e96f683f80eae166bbf22b1 # Parent f3f1d7a4a8d3ad7241e7ef7bfc017f5442adb92e G.next(...), G.valid(...), ... diff -r f3f1d7a4a8d3 -r 004fdf703abb src/work/bfs_iterator.hh --- a/src/work/bfs_iterator.hh Tue Mar 02 20:40:39 2004 +0000 +++ b/src/work/bfs_iterator.hh Wed Mar 03 14:30:38 2004 +0000 @@ -544,7 +544,7 @@ template > + typename ReachedMap/*=typename Graph::NodeMap*/ > class BfsIterator4 { typedef typename Graph::NodeIt NodeIt; const Graph& G; @@ -566,7 +566,7 @@ if (bfs_queue.empty()) { bfs_queue.push(s); G.getFirst(actual_edge, s); - if (actual_edge.valid()) { + if (G.valid(actual_edge)/*.valid()*/) { NodeIt w=G.bNode(actual_edge); if (!reached.get(w)) { bfs_queue.push(w); @@ -582,9 +582,9 @@ } BfsIterator4& operator++() { - if (actual_edge.valid()) { - ++actual_edge; - if (actual_edge.valid()) { + if (G.valid(actual_edge)/*.valid()*/) { + /*++*/G.next(actual_edge); + if (G.valid(actual_edge)/*.valid()*/) { NodeIt w=G.bNode(actual_edge); if (!reached.get(w)) { bfs_queue.push(w); @@ -598,7 +598,7 @@ bfs_queue.pop(); if (!bfs_queue.empty()) { G.getFirst(actual_edge, bfs_queue.front()); - if (actual_edge.valid()) { + if (G.valid(actual_edge)/*.valid()*/) { NodeIt w=G.bNode(actual_edge); if (!reached.get(w)) { bfs_queue.push(w); @@ -615,15 +615,95 @@ bool finished() const { return bfs_queue.empty(); } operator OutEdgeIt () const { return actual_edge; } bool isBNodeNewlyReached() const { return b_node_newly_reached; } - bool isANodeExamined() const { return !(actual_edge.valid()); } + bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); } NodeIt aNode() const { return bfs_queue.front(); } NodeIt bNode() const { return G.bNode(actual_edge); } const ReachedMap& getReachedMap() const { return reached; } const std::queue& getBfsQueue() const { return bfs_queue; } }; + + template */ > + class BfsIterator5 { + typedef typename GraphWrapper::NodeIt NodeIt; + GraphWrapper G; + std::queue bfs_queue; + ReachedMap& reached; + bool b_node_newly_reached; + OutEdgeIt actual_edge; + bool own_reached_map; + public: + BfsIterator5(const GraphWrapper& _G, ReachedMap& _reached) : + G(_G), reached(_reached), + own_reached_map(false) { } + BfsIterator5(const GraphWrapper& _G) : + G(_G), reached(*(new ReachedMap(G /*, false*/))), + own_reached_map(true) { } + ~BfsIterator5() { if (own_reached_map) delete &reached; } + void pushAndSetReached(NodeIt s) { + reached.set(s, true); + if (bfs_queue.empty()) { + bfs_queue.push(s); + G.getFirst(actual_edge, s); + if (G.valid(actual_edge)/*.valid()*/) { + NodeIt w=G.bNode(actual_edge); + if (!reached.get(w)) { + bfs_queue.push(w); + reached.set(w, true); + b_node_newly_reached=true; + } else { + b_node_newly_reached=false; + } + } + } else { + bfs_queue.push(s); + } + } + BfsIterator5& + operator++() { + if (G.valid(actual_edge)/*.valid()*/) { + /*++*/G.next(actual_edge); + if (G.valid(actual_edge)/*.valid()*/) { + NodeIt w=G.bNode(actual_edge); + if (!reached.get(w)) { + bfs_queue.push(w); + reached.set(w, true); + b_node_newly_reached=true; + } else { + b_node_newly_reached=false; + } + } + } else { + bfs_queue.pop(); + if (!bfs_queue.empty()) { + G.getFirst(actual_edge, bfs_queue.front()); + if (G.valid(actual_edge)/*.valid()*/) { + NodeIt w=G.bNode(actual_edge); + if (!reached.get(w)) { + bfs_queue.push(w); + reached.set(w, true); + b_node_newly_reached=true; + } else { + b_node_newly_reached=false; + } + } + } + } + return *this; + } + bool finished() const { return bfs_queue.empty(); } + operator OutEdgeIt () const { return actual_edge; } + bool isBNodeNewlyReached() const { return b_node_newly_reached; } + bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); } + NodeIt aNode() const { return bfs_queue.front(); } + NodeIt bNode() const { return G.bNode(actual_edge); } + const ReachedMap& getReachedMap() const { return reached; } + const std::queue& getBfsQueue() const { return bfs_queue; } + }; + template > + typename ReachedMap/*=typename Graph::NodeMap*/ > class DfsIterator4 { typedef typename Graph::NodeIt NodeIt; const Graph& G; @@ -650,7 +730,7 @@ operator++() { actual_edge=dfs_stack.top(); //actual_node=G.aNode(actual_edge); - if (actual_edge.valid()) { + if (G.valid(actual_edge)/*.valid()*/) { NodeIt w=G.bNode(actual_edge); actual_node=w; if (!reached.get(w)) { @@ -659,7 +739,7 @@ b_node_newly_reached=true; } else { actual_node=G.aNode(actual_edge); - ++(dfs_stack.top()); + /*++*/G.next(dfs_stack.top()); b_node_newly_reached=false; } } else { @@ -671,87 +751,68 @@ bool finished() const { return dfs_stack.empty(); } operator OutEdgeIt () const { return actual_edge; } bool isBNodeNewlyReached() const { return b_node_newly_reached; } - bool isANodeExamined() const { return !(actual_edge.valid()); } + bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); } NodeIt aNode() const { return actual_node; /*FIXME*/} NodeIt bNode() const { return G.bNode(actual_edge); } const ReachedMap& getReachedMap() const { return reached; } const std::stack& getDfsStack() const { return dfs_stack; } }; - - - template - class BfsIterator5 { + template */ > + class DfsIterator5 { typedef typename GraphWrapper::NodeIt NodeIt; - typedef typename GraphWrapper::OutEdgeIt OutEdgeIt; - GraphWrapper gw; - std::queue bfs_queue; - ReachedMap reached; + GraphWrapper G; + std::stack dfs_stack; bool b_node_newly_reached; OutEdgeIt actual_edge; + NodeIt actual_node; + ReachedMap& reached; + bool own_reached_map; public: - BfsIterator5(GraphWrapper _gw) : - gw(_gw), reached(_gw.getGraph()) { } + DfsIterator5(const GraphWrapper& _G, ReachedMap& _reached) : + G(_G), reached(_reached), + own_reached_map(false) { } + DfsIterator5(const GraphWrapper& _G) : + G(_G), reached(*(new ReachedMap(G /*, false*/))), + own_reached_map(true) { } + ~DfsIterator5() { if (own_reached_map) delete &reached; } void pushAndSetReached(NodeIt s) { + actual_node=s; reached.set(s, true); - if (bfs_queue.empty()) { - bfs_queue.push(s); - gw.getFirst(actual_edge, s); - if (actual_edge.valid()) { - NodeIt w=gw.bNode(actual_edge); - if (!reached.get(w)) { - bfs_queue.push(w); - reached.set(w, true); - b_node_newly_reached=true; - } else { - b_node_newly_reached=false; - } - } - } else { - bfs_queue.push(s); - } + dfs_stack.push(G.template first(s)); } - BfsIterator5& + DfsIterator5& operator++() { - if (actual_edge.valid()) { - ++actual_edge; - if (actual_edge.valid()) { - NodeIt w=gw.bNode(actual_edge); - if (!reached.get(w)) { - bfs_queue.push(w); - reached.set(w, true); - b_node_newly_reached=true; - } else { - b_node_newly_reached=false; - } + actual_edge=dfs_stack.top(); + //actual_node=G.aNode(actual_edge); + if (G.valid(actual_edge)/*.valid()*/) { + NodeIt w=G.bNode(actual_edge); + actual_node=w; + if (!reached.get(w)) { + dfs_stack.push(G.template first(w)); + reached.set(w, true); + b_node_newly_reached=true; + } else { + actual_node=G.aNode(actual_edge); + /*++*/G.next(dfs_stack.top()); + b_node_newly_reached=false; } } else { - bfs_queue.pop(); - if (!bfs_queue.empty()) { - gw.getFirst(actual_edge, bfs_queue.front()); - if (actual_edge.valid()) { - NodeIt w=gw.bNode(actual_edge); - if (!reached.get(w)) { - bfs_queue.push(w); - reached.set(w, true); - b_node_newly_reached=true; - } else { - b_node_newly_reached=false; - } - } - } + //actual_node=G.aNode(dfs_stack.top()); + dfs_stack.pop(); } return *this; } - bool finished() const { return bfs_queue.empty(); } + bool finished() const { return dfs_stack.empty(); } operator OutEdgeIt () const { return actual_edge; } bool isBNodeNewlyReached() const { return b_node_newly_reached; } - bool isANodeExamined() const { return !(actual_edge.valid()); } - NodeIt aNode() const { return bfs_queue.front(); } - NodeIt bNode() const { return gw.bNode(actual_edge); } + bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); } + NodeIt aNode() const { return actual_node; /*FIXME*/} + NodeIt bNode() const { return G.bNode(actual_edge); } const ReachedMap& getReachedMap() const { return reached; } - const std::queue& getBfsQueue() const { return bfs_queue; } - }; + const std::stack& getDfsStack() const { return dfs_stack; } + }; diff -r f3f1d7a4a8d3 -r 004fdf703abb src/work/edmonds_karp.hh --- a/src/work/edmonds_karp.hh Tue Mar 02 20:40:39 2004 +0000 +++ b/src/work/edmonds_karp.hh Wed Mar 03 14:30:38 2004 +0000 @@ -148,9 +148,9 @@ //OldSymEdgeIt sym; OldOutEdgeIt out; OldInEdgeIt in; - bool out_or_in; //1, iff out + bool out_or_in; //true, iff out public: - EdgeIt() : out_or_in(1) { } + EdgeIt() : out_or_in(true) { } Number free() const { if (out_or_in) { return (resG->capacity.get(out)-resG->flow.get(out)); @@ -246,30 +246,29 @@ }; template - class ResGraph3 { + class ResGraphWrapper { public: typedef typename Graph::NodeIt NodeIt; typedef typename Graph::EachNodeIt EachNodeIt; - private: - //typedef typename Graph::SymEdgeIt OldSymEdgeIt; typedef typename Graph::OutEdgeIt OldOutEdgeIt; typedef typename Graph::InEdgeIt OldInEdgeIt; - const Graph& G; - FlowMap& flow; - const CapacityMap& capacity; + const Graph* G; + FlowMap* flow; + const CapacityMap* capacity; public: - ResGraph3(const Graph& _G, FlowMap& _flow, + ResGraphWrapper(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) : - G(_G), flow(_flow), capacity(_capacity) { } - + G(&_G), flow(&_flow), capacity(&_capacity) { } +// ResGraphWrapper(const ResGraphWrapper& res_graph_wrapper) : +// G(res_graph_wrapper.G), flow(res_graph_wrapper.flow), capacity(res_graph_wrapper.capacity) { } class EdgeIt; class OutEdgeIt; friend class EdgeIt; friend class OutEdgeIt; class EdgeIt { - friend class ResGraph3; + friend class ResGraphWrapper; protected: //const ResGraph3* resG; const Graph* G; @@ -278,9 +277,11 @@ //OldSymEdgeIt sym; OldOutEdgeIt out; OldInEdgeIt in; - bool out_or_in; //1, iff out + bool out_or_in; //true, iff out public: - EdgeIt() : out_or_in(1) { } + EdgeIt() : out_or_in(true) { } + EdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) : + G(&_G), flow(&_flow), capacity(&_capacity), out_or_in(true) { } //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) { } Number free() const { if (out_or_in) { @@ -317,23 +318,27 @@ } }; + Number free(OldOutEdgeIt out) const { + return (/*resG->*/capacity->get(out)-/*resG->*/flow->get(out)); + } + Number free(OldInEdgeIt in) const { + return (/*resG->*/flow->get(in)); + } + class OutEdgeIt : public EdgeIt { - friend class ResGraph3; + friend class ResGraphWrapper; public: OutEdgeIt() { } private: - OutEdgeIt(const Graph& _G, NodeIt v, FlowMap& _flow, const CapacityMap& _capacity) { - G=&_G; - flow=&_flow; - capacity=&_capacity; + OutEdgeIt(const Graph& _G, NodeIt v, FlowMap& _flow, const CapacityMap& _capacity) : EdgeIt(_G, _flow, _capacity) { //out=/*resG->*/G->template first(v); G->getFirst(out, v); - while( out.valid() && !(free()>0) ) { ++out; } + while( out.valid() && !(EdgeIt::free()>0) ) { ++out; } if (!out.valid()) { out_or_in=0; //in=/*resG->*/G->template first(v); G->getFirst(in, v); - while( in.valid() && !(free()>0) ) { ++in; } + while( in.valid() && !(EdgeIt::free()>0) ) { ++in; } } } public: @@ -341,91 +346,141 @@ if (out_or_in) { NodeIt v=/*resG->*/G->aNode(out); ++out; - while( out.valid() && !(free()>0) ) { ++out; } + while( out.valid() && !(EdgeIt::free()>0) ) { ++out; } if (!out.valid()) { out_or_in=0; G->getFirst(in, v); //=/*resG->*/G->template first(v); - while( in.valid() && !(free()>0) ) { ++in; } + while( in.valid() && !(EdgeIt::free()>0) ) { ++in; } } } else { ++in; - while( in.valid() && !(free()>0) ) { ++in; } + while( in.valid() && !(EdgeIt::free()>0) ) { ++in; } } return *this; } }; class EachEdgeIt : public EdgeIt { + friend class ResGraphWrapper; typename Graph::EachNodeIt v; public: EachEdgeIt() { } //EachEdgeIt(const EachEdgeIt& e) : EdgeIt(e), v(e.v) { } - EachEdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) { - G=&_G; - flow=&_flow; - capacity=&_capacity; - out_or_in=1; + EachEdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) : EdgeIt(_G, _flow, _capacity) { + out_or_in=true; G->getFirst(v); if (v.valid()) G->getFirst(out, v); else out=OldOutEdgeIt(); - while (out.valid() && !(free()>0) ) { ++out; } + while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } while (v.valid() && !out.valid()) { ++v; if (v.valid()) G->getFirst(out, v); - while (out.valid() && !(free()>0) ) { ++out; } + while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } } if (!out.valid()) { out_or_in=0; G->getFirst(v); if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt(); - while (in.valid() && !(free()>0) ) { ++in; } + while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } while (v.valid() && !in.valid()) { ++v; if (v.valid()) G->getFirst(in, v); - while (in.valid() && !(free()>0) ) { ++in; } + while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } } } } EachEdgeIt& operator++() { if (out_or_in) { ++out; - while (out.valid() && !(free()>0) ) { ++out; } + while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } while (v.valid() && !out.valid()) { ++v; if (v.valid()) G->getFirst(out, v); - while (out.valid() && !(free()>0) ) { ++out; } + while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } } if (!out.valid()) { out_or_in=0; G->getFirst(v); if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt(); - while (in.valid() && !(free()>0) ) { ++in; } + while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } while (v.valid() && !in.valid()) { ++v; if (v.valid()) G->getFirst(in, v); - while (in.valid() && !(free()>0) ) { ++in; } + while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } } } } else { ++in; - while (in.valid() && !(free()>0) ) { ++in; } + while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } while (v.valid() && !in.valid()) { ++v; if (v.valid()) G->getFirst(in, v); - while (in.valid() && !(free()>0) ) { ++in; } + while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } } } return *this; } }; + void getFirst(EachNodeIt& v) const { G->getFirst(v); } void getFirst(OutEdgeIt& e, NodeIt v) const { - e=OutEdgeIt(G, v, flow, capacity); + e=OutEdgeIt(*G, v, *flow, *capacity); } void getFirst(EachEdgeIt& e) const { - e=EachEdgeIt(G, flow, capacity); + e=EachEdgeIt(*G, *flow, *capacity); } - void getFirst(EachNodeIt& v) const { G.getFirst(v); } + + EachNodeIt& next(EachNodeIt& n) const { return G->next(n); } + + OutEdgeIt& next(OutEdgeIt& e) const { + if (e.out_or_in) { + NodeIt v=G->aNode(e.out); + ++(e.out); + while( G->valid(e.out) && !(e.free()>0) ) { ++(e.out); } + if (!G->valid(e.out)) { + e.out_or_in=0; + G->getFirst(e.in, v); //=/*resG->*/G->template first(v); + while( G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } + } + } else { + ++(e.in); + while( G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } + } + return e; + } + + EachEdgeIt& next(EachEdgeIt& e) const { + if (e.out_or_in) { + ++(e.out); + while (G->valid(e.out) && !(e.free()>0) ) { ++(e.out); } + while (G->valid(e.v) && !G->valid(e.out)) { + ++(e.v); + if (G->valid(e.v)) G->getFirst(e.out, e.v); + while (G->valid(e.out) && !(e.free()>0) ) { ++(e.out); } + } + if (!G->valid(e.out)) { + e.out_or_in=0; + G->getFirst(e.v); + if (G->valid(e.v)) G->getFirst(e.in, e.v); else e.in=OldInEdgeIt(); + while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } + while (G->valid(e.v) && !G->valid(e.in)) { + ++(e.v); + if (G->valid(e.v)) G->getFirst(e.in, e.v); + while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } + } + } + } else { + ++(e.in); + while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } + while (G->valid(e.v) && !G->valid(e.in)) { + ++(e.v); + if (G->valid(e.v)) G->getFirst(e.in, e.v); + while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } + } + } + return e; + } + template< typename It > It first() const { It e; @@ -441,23 +496,27 @@ } NodeIt tail(EdgeIt e) const { - return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); } + return ((e.out_or_in) ? G->aNode(e.out) : G->aNode(e.in)); } NodeIt head(EdgeIt e) const { - return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); } + return ((e.out_or_in) ? G->bNode(e.out) : G->bNode(e.in)); } NodeIt aNode(OutEdgeIt e) const { - return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); } + return ((e.out_or_in) ? G->aNode(e.out) : G->aNode(e.in)); } NodeIt bNode(OutEdgeIt e) const { - return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); } + return ((e.out_or_in) ? G->bNode(e.out) : G->bNode(e.in)); } - int id(NodeIt v) const { return G.id(v); } + int id(NodeIt v) const { return G->id(v); } + + bool valid(NodeIt n) const { return G->valid(n); } + bool valid(EdgeIt e) const { + return e.out_or_in ? G->valid(e.out) : G->valid(e.in); } template class NodeMap { typename Graph::NodeMap node_map; public: - NodeMap(const ResGraph3& _G) : node_map(_G.G) { } - NodeMap(const ResGraph3& _G, T a) : node_map(_G.G, a) { } + NodeMap(const ResGraphWrapper& _G) : node_map(*(_G.G)) { } + NodeMap(const ResGraphWrapper& _G, T a) : node_map(*(_G.G), a) { } void set(NodeIt nit, T a) { node_map.set(nit, a); } T get(NodeIt nit) const { return node_map.get(nit); } }; @@ -466,8 +525,8 @@ class EdgeMap { typename Graph::EdgeMap forward_map, backward_map; public: - EdgeMap(const ResGraph3& _G) : forward_map(_G.G), backward_map(_G.G) { } - EdgeMap(const ResGraph3& _G, T a) : forward_map(_G.G, a), backward_map(_G.G, a) { } + EdgeMap(const ResGraphWrapper& _G) : forward_map(*(_G.G)), backward_map(*(_G.G)) { } + EdgeMap(const ResGraphWrapper& _G, T a) : forward_map(*(_G.G), a), backward_map(*(_G.G), a) { } void set(EdgeIt e, T a) { if (e.out_or_in) forward_map.set(e.out, a); @@ -494,12 +553,12 @@ typedef typename Graph::InEdgeIt InEdgeIt; private: - const Graph& G; + const Graph* G; NodeIt s; NodeIt t; - FlowMap& flow; - const CapacityMap& capacity; - typedef ResGraph3 AugGraph; + FlowMap* flow; + const CapacityMap* capacity; + typedef ResGraphWrapper AugGraph; typedef typename AugGraph::OutEdgeIt AugOutEdgeIt; typedef typename AugGraph::EdgeIt AugEdgeIt; @@ -509,15 +568,15 @@ //typename AugGraph::NodeMap free; public: MaxFlow(const Graph& _G, NodeIt _s, NodeIt _t, FlowMap& _flow, const CapacityMap& _capacity) : - G(_G), s(_s), t(_t), flow(_flow), capacity(_capacity) //, + G(&_G), s(_s), t(_t), flow(&_flow), capacity(&_capacity) //, //res_graph(G, flow, capacity), pred(res_graph), free(res_graph) { } bool augmentOnShortestPath() { - AugGraph res_graph(G, flow, capacity); + AugGraph res_graph(*G, *flow, *capacity); bool _augment=false; typedef typename AugGraph::NodeMap ReachedMap; - BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph); + BfsIterator5< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph); res_bfs.pushAndSetReached(s); typename AugGraph::NodeMap pred(res_graph); @@ -529,11 +588,11 @@ //searching for augmenting path while ( !res_bfs.finished() ) { AugOutEdgeIt e=/*AugOutEdgeIt*/(res_bfs); - if (e.valid() && res_bfs.isBNodeNewlyReached()) { + if (res_graph.valid(e) && res_bfs.isBNodeNewlyReached()) { NodeIt v=res_graph.tail(e); NodeIt w=res_graph.head(e); pred.set(w, e); - if (pred.get(v).valid()) { + if (res_graph.valid(pred.get(v))) { free.set(w, std::min(free.get(v), e.free())); } else { free.set(w, e.free()); @@ -547,7 +606,7 @@ if (_augment) { NodeIt n=t; Number augment_value=free.get(t); - while (pred.get(n).valid()) { + while (res_graph.valid(pred.get(n))) { AugEdgeIt e=pred.get(n); e.augment(augment_value); n=res_graph.tail(e); @@ -560,7 +619,7 @@ template bool augmentOnBlockingFlow() { bool _augment=false; - AugGraph res_graph(G, flow, capacity); + AugGraph res_graph(*G, *flow, *capacity); typedef typename AugGraph::NodeMap ReachedMap; BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > bfs(res_graph); @@ -569,7 +628,7 @@ typename AugGraph::NodeMap dist(res_graph); //filled up with 0's while ( !bfs.finished() ) { AugOutEdgeIt e=/*AugOutEdgeIt*/(bfs); - if (e.valid() && bfs.isBNodeNewlyReached()) { + if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) { dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1); } @@ -578,7 +637,7 @@ MutableGraph F; typename AugGraph::NodeMap res_graph_to_F(res_graph); - for(typename AugGraph::EachNodeIt n=res_graph.template first(); n.valid(); ++n) { + for(typename AugGraph::EachNodeIt n=res_graph.template first(); res_graph.valid(n); res_graph.next(n)) { res_graph_to_F.set(n, F.addNode()); } @@ -586,17 +645,17 @@ typename MutableGraph::NodeIt tF=res_graph_to_F.get(t); typename MutableGraph::EdgeMap original_edge(F); - typename MutableGraph::EdgeMap free_on_edge(F); + typename MutableGraph::EdgeMap residual_capacity(F); //Making F to the graph containing the edges of the residual graph //which are in some shortest paths - for(typename AugGraph::EachEdgeIt e=res_graph.template first(); e.valid(); ++e) { + for(typename AugGraph::EachEdgeIt e=res_graph.template first(); res_graph.valid(e); res_graph.next(e)) { if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) { typename MutableGraph::EdgeIt 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); - free_on_edge.update(); - free_on_edge.set(f, e.free()); + residual_capacity.update(); + residual_capacity.set(f, e.free()); } } @@ -613,7 +672,7 @@ dfs.pushAndSetReached(sF); while (!dfs.finished()) { ++dfs; - if (typename MutableGraph::OutEdgeIt(dfs).valid()) { + if (F.valid(typename MutableGraph::OutEdgeIt(dfs))) { //std::cout << "OutEdgeIt: " << dfs; //std::cout << " aNode: " << F.aNode(dfs); //std::cout << " bNode: " << F.bNode(dfs) << " "; @@ -621,10 +680,10 @@ typename MutableGraph::NodeIt v=F.aNode(dfs); typename MutableGraph::NodeIt w=F.bNode(dfs); pred.set(w, dfs); - if (pred.get(v).valid()) { - free.set(w, std::min(free.get(v), free_on_edge.get(dfs))); + if (F.valid(pred.get(v))) { + free.set(w, std::min(free.get(v), residual_capacity.get(dfs))); } else { - free.set(w, free_on_edge.get(dfs)/*original_edge.get(dfs).free()*/); + free.set(w, residual_capacity.get(dfs)/*original_edge.get(dfs).free()*/); } if (w==tF) { //std::cout << "AUGMENTATION"<(s); i.valid(); ++i) { - a+=flow.get(i); + OutEdgeIt e; + for(G->getFirst(e, s); G->valid(e); G->next(e)) { + a+=flow->get(e); } return a; } }; - -/* - template - class IteratorBoolNodeMap { - typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::EachNodeIt EachNodeIt; - class BoolItem { - public: - bool value; - NodeIt prev; - NodeIt next; - BoolItem() : value(false), prev(), next() {} - }; - NodeIt first_true; - //NodeIt last_true; - NodeIt first_false; - //NodeIt last_false; - const Graph& G; - typename Graph::NodeMap container; - public: - typedef bool ValueType; - typedef NodeIt KeyType; - IteratorBoolNodeMap(const Graph& _G) : G(_G), container(G), first_true(NodeIt()) { - //for (EachNodeIt e=G.template first(); e.valid(); ++e) { - //BoolItem b=container.get(e); - //b.me=e; - //container.set(b); - //} - G.getFirst(first_false); - NodeIt e_prev; - for (EachNodeIt e=G.template first(); e.valid(); ++e) { - container[e].prev=e_prev; - if (e_prev.valid()) container[e_prev].next=e; - e_prev=e; - } - } - //NodeMap(const Graph& _G, T a) : - // G(_G), container(G.node_id, a) { } - //FIXME - void set(NodeIt nit, T a) { container[G.id(nit)]=a; } - T get(NodeIt nit) const { return container[G.id(nit)]; } - //void update() { container.resize(G.node_id); } - //void update(T a) { container.resize(G.node_id, a); } - }; -*/ - template class MaxFlow2 { diff -r f3f1d7a4a8d3 -r 004fdf703abb src/work/list_graph.hh --- a/src/work/list_graph.hh Tue Mar 02 20:40:39 2004 +0000 +++ b/src/work/list_graph.hh Wed Mar 03 14:30:38 2004 +0000 @@ -302,8 +302,8 @@ return e; } + bool valid(NodeIt n) const { return n.valid(); } bool valid(EdgeIt e) const { return e.valid(); } - bool valid(NodeIt n) const { return n.valid(); } template It getNext(It it) const { It tmp(it); return next(tmp); } diff -r f3f1d7a4a8d3 -r 004fdf703abb src/work/marci/graph_wrapper.h --- a/src/work/marci/graph_wrapper.h Tue Mar 02 20:40:39 2004 +0000 +++ b/src/work/marci/graph_wrapper.h Wed Mar 03 14:30:38 2004 +0000 @@ -275,299 +275,300 @@ }; -// FIXME: comparison should be made better!!! - template - class ResGraphWrapper - { - Graph* graph; + +// // FIXME: comparison should be made better!!! +// template +// class ResGraphWrapper +// { +// Graph* graph; - public: - typedef Graph BaseGraph; +// public: +// typedef Graph BaseGraph; - typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::EdgeIt EdgeIt; +// typedef typename Graph::NodeIt NodeIt; +// typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::EachNodeIt EachNodeIt; +// typedef typename Graph::EachNodeIt EachNodeIt; - class OutEdgeIt { - public: - //Graph::NodeIt n; - bool out_or_in; - typename Graph::OutEdgeIt o; - typename Graph::InEdgeIt i; - }; - class InEdgeIt { - public: - //Graph::NodeIt n; - bool out_or_in; - typename Graph::OutEdgeIt o; - typename Graph::InEdgeIt i; - }; - typedef typename Graph::SymEdgeIt SymEdgeIt; - typedef typename Graph::EachEdgeIt EachEdgeIt; +// class OutEdgeIt { +// public: +// //Graph::NodeIt n; +// bool out_or_in; +// typename Graph::OutEdgeIt o; +// typename Graph::InEdgeIt i; +// }; +// class InEdgeIt { +// public: +// //Graph::NodeIt n; +// bool out_or_in; +// typename Graph::OutEdgeIt o; +// typename Graph::InEdgeIt i; +// }; +// typedef typename Graph::SymEdgeIt SymEdgeIt; +// typedef typename Graph::EachEdgeIt EachEdgeIt; - int nodeNum() const { return graph->nodeNum(); } - int edgeNum() const { return graph->edgeNum(); } +// int nodeNum() const { return graph->nodeNum(); } +// int edgeNum() const { return graph->edgeNum(); } - NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); } +// NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); } - // EachEdge and SymEdge is missing!!!! - // EdgeIt <-> In/OutEdgeIt conversion is missing!!!! +// // EachEdge and SymEdge is missing!!!! +// // EdgeIt <-> In/OutEdgeIt conversion is missing!!!! - //FIXME - OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const - { - e.n=n; - graph->getFirst(e.o,n); - while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) - graph->goNext(e.o); - if(!graph->valid(e.o)) { - graph->getFirst(e.i,n); - while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) - graph->goNext(e.i); - } - return e; - } -/* - OutEdgeIt &goNext(OutEdgeIt &e) - { - if(graph->valid(e.o)) { - while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) - graph->goNext(e.o); - if(graph->valid(e.o)) return e; - else graph->getFirst(e.i,e.n); - } - else { - while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) - graph->goNext(e.i); - return e; - } - } - OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} -*/ - //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} +// //FIXME +// OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const +// { +// e.n=n; +// graph->getFirst(e.o,n); +// while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) +// graph->goNext(e.o); +// if(!graph->valid(e.o)) { +// graph->getFirst(e.i,n); +// while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) +// graph->goNext(e.i); +// } +// return e; +// } +// /* +// OutEdgeIt &goNext(OutEdgeIt &e) +// { +// if(graph->valid(e.o)) { +// while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) +// graph->goNext(e.o); +// if(graph->valid(e.o)) return e; +// else graph->getFirst(e.i,e.n); +// } +// else { +// while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) +// graph->goNext(e.i); +// return e; +// } +// } +// OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} +// */ +// //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} - //FIXME - InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const - { - e.n=n; - graph->getFirst(e.i,n); - while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) - graph->goNext(e.i); - if(!graph->valid(e.i)) { - graph->getFirst(e.o,n); - while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) - graph->goNext(e.o); - } - return e; - } -/* - InEdgeIt &goNext(InEdgeIt &e) - { - if(graph->valid(e.i)) { - while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) - graph->goNext(e.i); - if(graph->valid(e.i)) return e; - else graph->getFirst(e.o,e.n); - } - else { - while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) - graph->goNext(e.o); - return e; - } - } - InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} -*/ - //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} +// //FIXME +// InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const +// { +// e.n=n; +// graph->getFirst(e.i,n); +// while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) +// graph->goNext(e.i); +// if(!graph->valid(e.i)) { +// graph->getFirst(e.o,n); +// while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) +// graph->goNext(e.o); +// } +// return e; +// } +// /* +// InEdgeIt &goNext(InEdgeIt &e) +// { +// if(graph->valid(e.i)) { +// while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) +// graph->goNext(e.i); +// if(graph->valid(e.i)) return e; +// else graph->getFirst(e.o,e.n); +// } +// else { +// while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) +// graph->goNext(e.o); +// return e; +// } +// } +// InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} +// */ +// //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} - //template I &goNext(I &i); { return graph->goNext(i); } - //template I next(const I i); { return graph->goNext(i); } +// //template I &goNext(I &i); { return graph->goNext(i); } +// //template I next(const I i); { return graph->goNext(i); } - template< typename It > It first() const { - It e; getFirst(e); return e; } +// template< typename It > It first() const { +// It e; getFirst(e); return e; } - template< typename It > It first(NodeIt v) const { - It e; getFirst(e, v); return e; } +// template< typename It > It first(NodeIt v) const { +// It e; getFirst(e, v); return e; } - NodeIt head(const EdgeIt& e) const { return graph->head(e); } - NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } +// NodeIt head(const EdgeIt& e) const { return graph->head(e); } +// NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } - template NodeIt aNode(const I& e) const { - return graph->aNode(e); } - template NodeIt bNode(const I& e) const { - return graph->bNode(e); } +// template NodeIt aNode(const I& e) const { +// return graph->aNode(e); } +// template NodeIt bNode(const I& e) const { +// return graph->bNode(e); } - //template bool valid(const I i); - //{ return graph->valid(i); } +// //template bool valid(const I i); +// //{ return graph->valid(i); } - //template void setInvalid(const I &i); - //{ return graph->setInvalid(i); } +// //template void setInvalid(const I &i); +// //{ return graph->setInvalid(i); } - NodeIt addNode() { return graph->addNode(); } - EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { - return graph->addEdge(tail, head); } +// NodeIt addNode() { return graph->addNode(); } +// EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { +// return graph->addEdge(tail, head); } - template void erase(const I& i) { graph->erase(i); } +// template void erase(const I& i) { graph->erase(i); } - void clear() { graph->clear(); } +// void clear() { graph->clear(); } - template class NodeMap : public Graph::NodeMap { }; - template class EdgeMap : public Graph::EdgeMap { }; +// template class NodeMap : public Graph::NodeMap { }; +// template class EdgeMap : public Graph::EdgeMap { }; - void setGraph(Graph& _graph) { graph = &_graph; } - Graph& getGraph() { return (*graph); } +// void setGraph(Graph& _graph) { graph = &_graph; } +// Graph& getGraph() { return (*graph); } - //ResGraphWrapper() : graph(0) { } - ResGraphWrapper(Graph& _graph) : graph(&_graph) { } - }; +// //ResGraphWrapper() : graph(0) { } +// ResGraphWrapper(Graph& _graph) : graph(&_graph) { } +// }; -// FIXME: comparison should be made better!!! - template - class ConstResGraphWrapper - { - const Graph* graph; - const LowerMap* low; - FlowMap* flow; - const UpperMap* up; - public: - typedef Graph BaseGraph; +// // FIXME: comparison should be made better!!! +// template +// class ConstResGraphWrapper +// { +// const Graph* graph; +// const LowerMap* low; +// FlowMap* flow; +// const UpperMap* up; +// public: +// typedef Graph BaseGraph; - typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::EdgeIt EdgeIt; +// typedef typename Graph::NodeIt NodeIt; +// typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::EachNodeIt EachNodeIt; +// typedef typename Graph::EachNodeIt EachNodeIt; - class OutEdgeIt { - public: - //Graph::NodeIt n; - bool out_or_in; - typename Graph::SymEdgeIt sym; - }; - class InEdgeIt { - public: - //Graph::NodeIt n; - bool out_or_in; - typename Graph::OutEdgeIt sym; - }; - //typedef typename Graph::SymEdgeIt SymEdgeIt; - //typedef typename Graph::EachEdgeIt EachEdgeIt; +// class OutEdgeIt { +// public: +// //Graph::NodeIt n; +// bool out_or_in; +// typename Graph::SymEdgeIt sym; +// }; +// class InEdgeIt { +// public: +// //Graph::NodeIt n; +// bool out_or_in; +// typename Graph::OutEdgeIt sym; +// }; +// //typedef typename Graph::SymEdgeIt SymEdgeIt; +// //typedef typename Graph::EachEdgeIt EachEdgeIt; - int nodeNum() const { return graph->nodeNum(); } - //int edgeNum() const { return graph->edgeNum(); } +// int nodeNum() const { return graph->nodeNum(); } +// //int edgeNum() const { return graph->edgeNum(); } - NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); } +// NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); } - // EachEdge and SymEdge is missing!!!! - // EdgeIt <-> In/OutEdgeIt conversion is missing!!!! +// // EachEdge and SymEdge is missing!!!! +// // EdgeIt <-> In/OutEdgeIt conversion is missing!!!! - //FIXME - OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const - { - e.n=n; - graph->getFirst(e.o,n); - while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) - graph->goNext(e.o); - if(!graph->valid(e.o)) { - graph->getFirst(e.i,n); - while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) - graph->goNext(e.i); - } - return e; - } -/* - OutEdgeIt &goNext(OutEdgeIt &e) - { - if(graph->valid(e.o)) { - while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) - graph->goNext(e.o); - if(graph->valid(e.o)) return e; - else graph->getFirst(e.i,e.n); - } - else { - while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) - graph->goNext(e.i); - return e; - } - } - OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} -*/ - //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} +// //FIXME +// OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const +// { +// e.n=n; +// graph->getFirst(e.o,n); +// while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) +// graph->goNext(e.o); +// if(!graph->valid(e.o)) { +// graph->getFirst(e.i,n); +// while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) +// graph->goNext(e.i); +// } +// return e; +// } +// /* +// OutEdgeIt &goNext(OutEdgeIt &e) +// { +// if(graph->valid(e.o)) { +// while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) +// graph->goNext(e.o); +// if(graph->valid(e.o)) return e; +// else graph->getFirst(e.i,e.n); +// } +// else { +// while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) +// graph->goNext(e.i); +// return e; +// } +// } +// OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} +// */ +// //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} - //FIXME - InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const - { - e.n=n; - graph->getFirst(e.i,n); - while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) - graph->goNext(e.i); - if(!graph->valid(e.i)) { - graph->getFirst(e.o,n); - while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) - graph->goNext(e.o); - } - return e; - } -/* - InEdgeIt &goNext(InEdgeIt &e) - { - if(graph->valid(e.i)) { - while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) - graph->goNext(e.i); - if(graph->valid(e.i)) return e; - else graph->getFirst(e.o,e.n); - } - else { - while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) - graph->goNext(e.o); - return e; - } - } - InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} -*/ - //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} +// //FIXME +// InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const +// { +// e.n=n; +// graph->getFirst(e.i,n); +// while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) +// graph->goNext(e.i); +// if(!graph->valid(e.i)) { +// graph->getFirst(e.o,n); +// while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) +// graph->goNext(e.o); +// } +// return e; +// } +// /* +// InEdgeIt &goNext(InEdgeIt &e) +// { +// if(graph->valid(e.i)) { +// while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) +// graph->goNext(e.i); +// if(graph->valid(e.i)) return e; +// else graph->getFirst(e.o,e.n); +// } +// else { +// while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) +// graph->goNext(e.o); +// return e; +// } +// } +// InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} +// */ +// //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} - //template I &goNext(I &i); { return graph->goNext(i); } - //template I next(const I i); { return graph->goNext(i); } +// //template I &goNext(I &i); { return graph->goNext(i); } +// //template I next(const I i); { return graph->goNext(i); } - template< typename It > It first() const { - It e; getFirst(e); return e; } +// template< typename It > It first() const { +// It e; getFirst(e); return e; } - template< typename It > It first(NodeIt v) const { - It e; getFirst(e, v); return e; } +// template< typename It > It first(NodeIt v) const { +// It e; getFirst(e, v); return e; } - NodeIt head(const EdgeIt& e) const { return graph->head(e); } - NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } +// NodeIt head(const EdgeIt& e) const { return graph->head(e); } +// NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } - template NodeIt aNode(const I& e) const { - return graph->aNode(e); } - template NodeIt bNode(const I& e) const { - return graph->bNode(e); } +// template NodeIt aNode(const I& e) const { +// return graph->aNode(e); } +// template NodeIt bNode(const I& e) const { +// return graph->bNode(e); } - //template bool valid(const I i); - //{ return graph->valid(i); } +// //template bool valid(const I i); +// //{ return graph->valid(i); } - //template void setInvalid(const I &i); - //{ return graph->setInvalid(i); } +// //template void setInvalid(const I &i); +// //{ return graph->setInvalid(i); } - NodeIt addNode() { return graph->addNode(); } - EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { - return graph->addEdge(tail, head); } +// NodeIt addNode() { return graph->addNode(); } +// EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { +// return graph->addEdge(tail, head); } - template void erase(const I& i) { graph->erase(i); } +// template void erase(const I& i) { graph->erase(i); } - void clear() { graph->clear(); } +// void clear() { graph->clear(); } - template class NodeMap : public Graph::NodeMap { }; - template class EdgeMap : public Graph::EdgeMap { }; +// template class NodeMap : public Graph::NodeMap { }; +// template class EdgeMap : public Graph::EdgeMap { }; - void setGraph(const Graph& _graph) { graph = &_graph; } - const Graph& getGraph() { return (*graph); } +// void setGraph(const Graph& _graph) { graph = &_graph; } +// const Graph& getGraph() { return (*graph); } - //ConstResGraphWrapper() : graph(0) { } - ConstResGraphWrapper(const Graph& _graph) : graph(&_graph) { } - }; +// //ConstResGraphWrapper() : graph(0) { } +// ConstResGraphWrapper(const Graph& _graph) : graph(&_graph) { } +// };