# HG changeset patch # User marci # Date 1082040080 0 # Node ID 7ac0d4e8a31c60fb2c85c62a81dcddcaa53be520 # Parent 0dade87d013ba832e154d0a089eefd20a46a7202 In the resgraphwrapper interface, and in the constructor, the order of FlowMap and CapacityMap is changed. diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/athos/minlengthpaths.h --- a/src/work/athos/minlengthpaths.h Thu Apr 15 08:06:43 2004 +0000 +++ b/src/work/athos/minlengthpaths.h Thu Apr 15 14:41:20 2004 +0000 @@ -37,7 +37,7 @@ typedef ConstMap ConstMap; - typedef ResGraphWrapper ResGraphType; + typedef ResGraphWrapper ResGraphType; class ModLengthMap { @@ -92,7 +92,7 @@ ConstMap const1map(1); //We need a residual graph, in which some of the edges are reversed - ResGraphType res_graph(G, reversed, const1map); + ResGraphType res_graph(G, const1map, reversed); //Initialize the copy of the Dijkstra potential to zero typename ResGraphType::NodeMap dijkstra_dist(res_graph); diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/jacint/preflow.h --- a/src/work/jacint/preflow.h Thu Apr 15 08:06:43 2004 +0000 +++ b/src/work/jacint/preflow.h Thu Apr 15 14:41:20 2004 +0000 @@ -43,8 +43,8 @@ namespace hugo { template , - typename CapMap=typename Graph::EdgeMap > + typename CapMap=typename Graph::EdgeMap, + typename FlowMap=typename Graph::EdgeMap > class Preflow { typedef typename Graph::Node Node; @@ -56,15 +56,14 @@ const Graph& G; Node s; Node t; + const CapMap& capacity; FlowMap& flow; - const CapMap& capacity; T value; public: Preflow(const Graph& _G, Node _s, Node _t, const CapMap& _capacity, FlowMap& _flow ) : - G(_G), s(_s), t(_t), flow(_flow), capacity(_capacity) {} - + G(_G), s(_s), t(_t), capacity(_capacity), flow(_flow) {} void run() { diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/marci/edmonds_karp.h --- a/src/work/marci/edmonds_karp.h Thu Apr 15 08:06:43 2004 +0000 +++ b/src/work/marci/edmonds_karp.h Thu Apr 15 14:41:20 2004 +0000 @@ -13,243 +13,243 @@ namespace hugo { - template - class ResGraph { - public: - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - private: - typedef typename Graph::SymEdgeIt OldSymEdgeIt; - const Graph& G; - FlowMap& flow; - const CapacityMap& capacity; - public: - ResGraph(const Graph& _G, FlowMap& _flow, - const CapacityMap& _capacity) : - G(_G), flow(_flow), capacity(_capacity) { } +// template +// class ResGraph { +// public: +// typedef typename Graph::Node Node; +// typedef typename Graph::NodeIt NodeIt; +// private: +// typedef typename Graph::SymEdgeIt OldSymEdgeIt; +// const Graph& G; +// const CapacityMap& capacity; +// FlowMap& flow; +// public: +// ResGraph(const Graph& _G, const CapacityMap& _capacity, FlowMap& _flow) : +// G(_G), capacity(_capacity), flow(_flow) { } - class Edge; - class OutEdgeIt; - friend class Edge; - friend class OutEdgeIt; +// class Edge; +// class OutEdgeIt; +// friend class Edge; +// friend class OutEdgeIt; - class Edge { - friend class ResGraph; - protected: - const ResGraph* resG; - OldSymEdgeIt sym; - public: - Edge() { } - //Edge(const Edge& e) : resG(e.resG), sym(e.sym) { } - Number free() const { - if (resG->G.aNode(sym)==resG->G.tail(sym)) { - return (resG->capacity.get(sym)-resG->flow.get(sym)); - } else { - return (resG->flow.get(sym)); - } - } - bool valid() const { return sym.valid(); } - void augment(Number a) const { - if (resG->G.aNode(sym)==resG->G.tail(sym)) { - resG->flow.set(sym, resG->flow.get(sym)+a); - //resG->flow[sym]+=a; - } else { - resG->flow.set(sym, resG->flow.get(sym)-a); - //resG->flow[sym]-=a; - } - } - }; +// class Edge { +// friend class ResGraph; +// protected: +// const ResGraph* resG; +// OldSymEdgeIt sym; +// public: +// Edge() { } +// //Edge(const Edge& e) : resG(e.resG), sym(e.sym) { } +// Number free() const { +// if (resG->G.aNode(sym)==resG->G.tail(sym)) { +// return (resG->capacity.get(sym)-resG->flow.get(sym)); +// } else { +// return (resG->flow.get(sym)); +// } +// } +// bool valid() const { return sym.valid(); } +// void augment(Number a) const { +// if (resG->G.aNode(sym)==resG->G.tail(sym)) { +// resG->flow.set(sym, resG->flow.get(sym)+a); +// //resG->flow[sym]+=a; +// } else { +// resG->flow.set(sym, resG->flow.get(sym)-a); +// //resG->flow[sym]-=a; +// } +// } +// }; - class OutEdgeIt : public Edge { - friend class ResGraph; - public: - OutEdgeIt() { } - //OutEdgeIt(const OutEdgeIt& e) { resG=e.resG; sym=e.sym; } - private: - OutEdgeIt(const ResGraph& _resG, Node v) { - resG=&_resG; - sym=resG->G.template first(v); - while( sym.valid() && !(free()>0) ) { ++sym; } - } - public: - OutEdgeIt& operator++() { - ++sym; - while( sym.valid() && !(free()>0) ) { ++sym; } - return *this; - } - }; +// class OutEdgeIt : public Edge { +// friend class ResGraph; +// public: +// OutEdgeIt() { } +// //OutEdgeIt(const OutEdgeIt& e) { resG=e.resG; sym=e.sym; } +// private: +// OutEdgeIt(const ResGraph& _resG, Node v) { +// resG=&_resG; +// sym=resG->G.template first(v); +// while( sym.valid() && !(free()>0) ) { ++sym; } +// } +// public: +// OutEdgeIt& operator++() { +// ++sym; +// while( sym.valid() && !(free()>0) ) { ++sym; } +// return *this; +// } +// }; - void /*getF*/first(OutEdgeIt& e, Node v) const { - e=OutEdgeIt(*this, v); - } - void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); } +// void /*getF*/first(OutEdgeIt& e, Node v) const { +// e=OutEdgeIt(*this, v); +// } +// void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); } - template< typename It > - It first() const { - It e; - /*getF*/first(e); - return e; - } +// template< typename It > +// It first() const { +// It e; +// /*getF*/first(e); +// return e; +// } - template< typename It > - It first(Node v) const { - It e; - /*getF*/first(e, v); - return e; - } +// template< typename It > +// It first(Node v) const { +// It e; +// /*getF*/first(e, v); +// return e; +// } - Node tail(Edge e) const { return G.aNode(e.sym); } - Node head(Edge e) const { return G.bNode(e.sym); } +// Node tail(Edge e) const { return G.aNode(e.sym); } +// Node head(Edge e) const { return G.bNode(e.sym); } - Node aNode(OutEdgeIt e) const { return G.aNode(e.sym); } - Node bNode(OutEdgeIt e) const { return G.bNode(e.sym); } +// Node aNode(OutEdgeIt e) const { return G.aNode(e.sym); } +// Node bNode(OutEdgeIt e) const { return G.bNode(e.sym); } - int id(Node v) const { return G.id(v); } +// int id(Node v) const { return G.id(v); } - template - class NodeMap { - typename Graph::NodeMap node_map; - public: - NodeMap(const ResGraph& _G) : node_map(_G.G) { } - NodeMap(const ResGraph& _G, S a) : node_map(_G.G, a) { } - void set(Node nit, S a) { node_map.set(nit, a); } - S get(Node nit) const { return node_map.get(nit); } - S& operator[](Node nit) { return node_map[nit]; } - const S& operator[](Node nit) const { return node_map[nit]; } - }; +// template +// class NodeMap { +// typename Graph::NodeMap node_map; +// public: +// NodeMap(const ResGraph& _G) : node_map(_G.G) { } +// NodeMap(const ResGraph& _G, S a) : node_map(_G.G, a) { } +// void set(Node nit, S a) { node_map.set(nit, a); } +// S get(Node nit) const { return node_map.get(nit); } +// S& operator[](Node nit) { return node_map[nit]; } +// const S& operator[](Node nit) const { return node_map[nit]; } +// }; - }; +// }; - template - class ResGraph2 { - public: - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - private: - //typedef typename Graph::SymEdgeIt OldSymEdgeIt; - typedef typename Graph::OutEdgeIt OldOutEdgeIt; - typedef typename Graph::InEdgeIt OldInEdgeIt; +// template +// class ResGraph2 { +// public: +// typedef typename Graph::Node Node; +// typedef typename Graph::NodeIt NodeIt; +// private: +// //typedef typename Graph::SymEdgeIt OldSymEdgeIt; +// typedef typename Graph::OutEdgeIt OldOutEdgeIt; +// typedef typename Graph::InEdgeIt OldInEdgeIt; - const Graph& G; - FlowMap& flow; - const CapacityMap& capacity; - public: - ResGraph2(const Graph& _G, FlowMap& _flow, - const CapacityMap& _capacity) : - G(_G), flow(_flow), capacity(_capacity) { } +// const Graph& G; +// FlowMap& flow; +// const CapacityMap& capacity; +// public: +// ResGraph2(const Graph& _G, FlowMap& _flow, +// const CapacityMap& _capacity) : +// G(_G), flow(_flow), capacity(_capacity) { } - class Edge; - class OutEdgeIt; - friend class Edge; - friend class OutEdgeIt; +// class Edge; +// class OutEdgeIt; +// friend class Edge; +// friend class OutEdgeIt; - class Edge { - friend class ResGraph2; - protected: - const ResGraph2* resG; - //OldSymEdgeIt sym; - OldOutEdgeIt out; - OldInEdgeIt in; - bool out_or_in; //true, iff out - public: - Edge() : out_or_in(true) { } - Number free() const { - if (out_or_in) { - return (resG->capacity.get(out)-resG->flow.get(out)); - } else { - return (resG->flow.get(in)); - } - } - bool valid() const { - return out_or_in && out.valid() || in.valid(); } - void augment(Number a) const { - if (out_or_in) { - resG->flow.set(out, resG->flow.get(out)+a); - } else { - resG->flow.set(in, resG->flow.get(in)-a); - } - } - }; +// class Edge { +// friend class ResGraph2; +// protected: +// const ResGraph2* resG; +// //OldSymEdgeIt sym; +// OldOutEdgeIt out; +// OldInEdgeIt in; +// bool out_or_in; //true, iff out +// public: +// Edge() : out_or_in(true) { } +// Number free() const { +// if (out_or_in) { +// return (resG->capacity.get(out)-resG->flow.get(out)); +// } else { +// return (resG->flow.get(in)); +// } +// } +// bool valid() const { +// return out_or_in && out.valid() || in.valid(); } +// void augment(Number a) const { +// if (out_or_in) { +// resG->flow.set(out, resG->flow.get(out)+a); +// } else { +// resG->flow.set(in, resG->flow.get(in)-a); +// } +// } +// }; - class OutEdgeIt : public Edge { - friend class ResGraph2; - public: - OutEdgeIt() { } - private: - OutEdgeIt(const ResGraph2& _resG, Node v) { - resG=&_resG; - out=resG->G.template first(v); - while( out.valid() && !(free()>0) ) { ++out; } - if (!out.valid()) { - out_or_in=0; - in=resG->G.template first(v); - while( in.valid() && !(free()>0) ) { ++in; } - } - } - public: - OutEdgeIt& operator++() { - if (out_or_in) { - Node v=resG->G.aNode(out); - ++out; - while( out.valid() && !(free()>0) ) { ++out; } - if (!out.valid()) { - out_or_in=0; - in=resG->G.template first(v); - while( in.valid() && !(free()>0) ) { ++in; } - } - } else { - ++in; - while( in.valid() && !(free()>0) ) { ++in; } - } - return *this; - } - }; +// class OutEdgeIt : public Edge { +// friend class ResGraph2; +// public: +// OutEdgeIt() { } +// private: +// OutEdgeIt(const ResGraph2& _resG, Node v) { +// resG=&_resG; +// out=resG->G.template first(v); +// while( out.valid() && !(free()>0) ) { ++out; } +// if (!out.valid()) { +// out_or_in=0; +// in=resG->G.template first(v); +// while( in.valid() && !(free()>0) ) { ++in; } +// } +// } +// public: +// OutEdgeIt& operator++() { +// if (out_or_in) { +// Node v=resG->G.aNode(out); +// ++out; +// while( out.valid() && !(free()>0) ) { ++out; } +// if (!out.valid()) { +// out_or_in=0; +// in=resG->G.template first(v); +// while( in.valid() && !(free()>0) ) { ++in; } +// } +// } else { +// ++in; +// while( in.valid() && !(free()>0) ) { ++in; } +// } +// return *this; +// } +// }; - void /*getF*/first(OutEdgeIt& e, Node v) const { - e=OutEdgeIt(*this, v); - } - void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); } +// void /*getF*/first(OutEdgeIt& e, Node v) const { +// e=OutEdgeIt(*this, v); +// } +// void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); } - template< typename It > - It first() const { - It e; - /*getF*/first(e); - return e; - } +// template< typename It > +// It first() const { +// It e; +// /*getF*/first(e); +// return e; +// } - template< typename It > - It first(Node v) const { - It e; - /*getF*/first(e, v); - return e; - } +// template< typename It > +// It first(Node v) const { +// It e; +// /*getF*/first(e, v); +// return e; +// } - Node tail(Edge e) const { - return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); } - Node head(Edge e) const { - return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); } +// Node tail(Edge e) const { +// return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); } +// Node head(Edge e) const { +// return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); } - Node aNode(OutEdgeIt e) const { - return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); } - Node bNode(OutEdgeIt e) const { - return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); } +// Node aNode(OutEdgeIt e) const { +// return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); } +// Node bNode(OutEdgeIt e) const { +// return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); } - int id(Node v) const { return G.id(v); } +// int id(Node v) const { return G.id(v); } - template - class NodeMap { - typename Graph::NodeMap node_map; - public: - NodeMap(const ResGraph2& _G) : node_map(_G.G) { } - NodeMap(const ResGraph2& _G, S a) : node_map(_G.G, a) { } - void set(Node nit, S a) { node_map.set(nit, a); } - S get(Node nit) const { return node_map.get(nit); } - }; - }; +// template +// class NodeMap { +// typename Graph::NodeMap node_map; +// public: +// NodeMap(const ResGraph2& _G) : node_map(_G.G) { } +// NodeMap(const ResGraph2& _G, S a) : node_map(_G.G, a) { } +// void set(Node nit, S a) { node_map.set(nit, a); } +// S get(Node nit) const { return node_map.get(nit); } +// }; +// }; - template + template class MaxFlow { protected: typedef typename Graph::Node Node; @@ -260,18 +260,19 @@ const Graph* g; Node s; Node t; + const CapacityMap* capacity; FlowMap* flow; - const CapacityMap* capacity; - typedef ResGraphWrapper ResGW; + typedef ResGraphWrapper ResGW; typedef typename ResGW::OutEdgeIt ResGWOutEdgeIt; typedef typename ResGW::Edge ResGWEdge; 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 Graph& _g, Node _s, Node _t, const CapacityMap& _capacity, + FlowMap& _flow) : + g(&_g), s(_s), t(_t), capacity(&_capacity), flow(&_flow) { } bool augmentOnShortestPath() { - ResGW res_graph(*g, *flow, *capacity); + ResGW res_graph(*g, *capacity, *flow); bool _augment=false; BfsIterator5< ResGW, typename ResGW::NodeMap > bfs(res_graph); @@ -336,7 +337,7 @@ typedef MutableGraph MG; bool _augment=false; - ResGW res_graph(*g, *flow, *capacity); + ResGW res_graph(*g, *capacity, *flow); BfsIterator5< ResGW, typename ResGW::NodeMap > bfs(res_graph); @@ -445,7 +446,7 @@ typedef MutableGraph MG; bool _augment=false; - ResGW res_graph(*g, *flow, *capacity); + ResGW res_graph(*g, *capacity, *flow); //bfs for distances on the residual graph BfsIterator5< ResGW, typename ResGW::NodeMap > bfs(res_graph); @@ -550,7 +551,7 @@ bool augmentOnBlockingFlow2() { bool _augment=false; - ResGW res_graph(*g, *flow, *capacity); + ResGW res_graph(*g, *capacity, *flow); BfsIterator5< ResGW, typename ResGW::NodeMap > bfs(res_graph); diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/marci/edmonds_karp_demo.cc --- a/src/work/marci/edmonds_karp_demo.cc Thu Apr 15 08:06:43 2004 +0000 +++ b/src/work/marci/edmonds_karp_demo.cc Thu Apr 15 14:41:20 2004 +0000 @@ -104,7 +104,7 @@ ts.reset(); MaxFlow, Graph::EdgeMap > - max_flow_test(G, s, t, flow, cap); + max_flow_test(G, s, t, cap, flow); int i=0; while (max_flow_test.augmentOnBlockingFlow()) { // for(EdgeIt e=G.template first(); e.valid(); ++e) { @@ -132,7 +132,7 @@ ts.reset(); MaxFlow, Graph::EdgeMap > - max_flow_test(G, s, t, flow, cap); + max_flow_test(G, s, t, cap, flow); int i=0; while (max_flow_test.augmentOnBlockingFlow1()) { // for(EdgeIt e=G.template first(); e.valid(); ++e) { @@ -160,7 +160,7 @@ ts.reset(); MaxFlow, Graph::EdgeMap > - max_flow_test(G, s, t, flow, cap); + max_flow_test(G, s, t, cap, flow); int i=0; while (max_flow_test.augmentOnBlockingFlow2()) { // for(EdgeIt e=G.template first(); e.valid(); ++e) { @@ -188,7 +188,7 @@ ts.reset(); MaxFlow, Graph::EdgeMap > - max_flow_test(G, s, t, flow, cap); + max_flow_test(G, s, t, cap, flow); int i=0; while (max_flow_test.augmentOnShortestPath()) { // for(EdgeIt e=G.template first(); e.valid(); ++e) { diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/marci/for_each_macros.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/marci/for_each_macros.h Thu Apr 15 14:41:20 2004 +0000 @@ -0,0 +1,85 @@ +// -*- c++ -*- +#ifndef FOR_EACH_MACROS_H +#define FOR_EACH_MACROS_H + +namespace hugo { + +#define FOR_EACH(e, g) for((g).first((e)); (g).valid((e)); (g).next((e))) +#define FOR_EACH_INC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e))) + +#define FOR_EACH_EDGE(e, g) for((g).first((e)); (g).valid((e)); (g).next((e))) +#define FOR_EACH_NODE(e, g) for((g).first((e)); (g).valid((e)); (g).next((e))) +#define FOR_EACH_INEDGE(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e))) +#define FOR_EACH_OUTEDGE(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e))) + +// template +// It loopFirst(const Graph& g) const { +// It e; g.first(e); return e; +// } + +// template +// It loopFirst(const Graph& g, const Node& v) const { +// It e; g.first(e, v); return e; +// } + +// template +// typename Graph::NodeIt loopFirstNode(const Graph& g) const { +// typename Graph::NodeIt e; g.first(e); return e; +// } +// template +// typename Graph::EdgeIt loopFirstEdge(const Graph& g) const { +// typename Graph::EdgeIt e; g.first(e); return e; +// } +// template +// typename Graph::OutEdgeIt +// loopFirstOutEdge(const Graph& g, const Node& n) const { +// typename Graph::OutEdgeIt e; g.first(e, n); return e; +// } +// template +// typename Graph::InEdgeIt +// loopFirstIn Edge(const Graph& g, const Node& n) const { +// typename Graph::InEdgeIt e; g.first(e, n); return e; +// } + +//FIXME ezt hogy a gorcsbe birja levezetni. Csak ugy leveszi a const-ot?? + template + It loopFirst(const It& i, const Graph& g) { + It e=i; g.first(e); return e; + } + + template + It loopFirst(const It& i, const Graph& g, const Node& v) { + It e=i; g.first(e, v); return e; + } + +// template +// typename Graph::NodeIt loopFirstNode(const Graph& g) const { +// typename Graph::NodeIt e; g.first(e); return e; +// } +// template +// typename Graph::EdgeIt loopFirstEdge(const Graph& g) const { +// typename Graph::EdgeIt e; g.first(e); return e; +// } +// template +// typename Graph::OutEdgeIt +// loopFirstOutEdge(const Graph& g, const Node& n) const { +// typename Graph::OutEdgeIt e; g.first(e, n); return e; +// } +// template +// typename Graph::InEdgeIt +// loopFirstIn Edge(const Graph& g, const Node& n) const { +// typename Graph::InEdgeIt e; g.first(e, n); return e; +// } + +#define FOR_EACH_LOC(Ittype, e, g) for(Ittype (e)=loopFirst(Ittype(), (g)); (g).valid((e)); (g).next((e))) +#define FOR_EACH_INC_LOC(Ittype, e, g, v) for(Ittype (e)=loopFirst(Ittype(), (g), (v)); (g).valid((e)); (g).next((e))) + +// #define FOR_EACH_EDGE_LOC(e, g) for((g).first((e)); (g).valid((e)); (g).next((e))) +// #define FOR_EACH_NODE_LOC(e, g) for((g).first((e)); (g).valid((e)); (g).next((e))) +// #define FOR_EACH_INEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e))) +// #define FOR_EACH_OUTEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e))) + + +} //namespace hugo + +#endif //FOR_EACH_MACROS_H diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/marci/graph_wrapper.h --- a/src/work/marci/graph_wrapper.h Thu Apr 15 08:06:43 2004 +0000 +++ b/src/work/marci/graph_wrapper.h Thu Apr 15 14:41:20 2004 +0000 @@ -896,19 +896,20 @@ - template + template class ResGraphWrapper : public GraphWrapper { protected: // typedef typename Graph::OutEdgeIt GraphOutEdgeIt; // typedef typename Graph::InEdgeIt GraphInEdgeIt; // typedef typename Graph::Edge GraphEdge; + const CapacityMap* capacity; FlowMap* flow; - const CapacityMap* capacity; public: - ResGraphWrapper(Graph& _graph, FlowMap& _flow, - const CapacityMap& _capacity) : - GraphWrapper(_graph), flow(&_flow), capacity(&_capacity) { } + ResGraphWrapper(Graph& _graph, const CapacityMap& _capacity, + FlowMap& _flow) : + GraphWrapper(_graph), capacity(&_capacity), flow(&_flow) { } class Edge; class OutEdgeIt; @@ -918,7 +919,7 @@ typedef typename GraphWrapper::Node Node; typedef typename GraphWrapper::NodeIt NodeIt; class Edge : public Graph::Edge { - friend class ResGraphWrapper; + friend class ResGraphWrapper; protected: bool forward; //true, iff forward // typename Graph::Edge e; @@ -940,7 +941,7 @@ } }; // class Edge { -// friend class ResGraphWrapper; +// friend class ResGraphWrapper; // protected: // bool out_or_in; //true, iff out // GraphOutEdgeIt out; @@ -967,7 +968,7 @@ // } // }; class OutEdgeIt { - friend class ResGraphWrapper; + friend class ResGraphWrapper; protected: typename Graph::OutEdgeIt out; typename Graph::InEdgeIt in; @@ -978,7 +979,7 @@ // OutEdgeIt(const Edge& e) : Edge(e) { } OutEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { } //the unique invalid iterator - OutEdgeIt(const ResGraphWrapper& resG, Node v) { + OutEdgeIt(const ResGraphWrapper& resG, Node v) { forward=true; resG.graph->first(out, v); while( resG.graph->valid(out) && !(resG.resCap(*this)>0) ) { resG.graph->next(out); } @@ -1000,13 +1001,13 @@ } }; // class OutEdgeIt : public Edge { -// friend class ResGraphWrapper; +// friend class ResGraphWrapper; // public: // OutEdgeIt() { } // //FIXME // OutEdgeIt(const Edge& e) : Edge(e) { } // OutEdgeIt(const Invalid& i) : Edge(i) { } -// OutEdgeIt(const ResGraphWrapper& resG, Node v) : Edge() { +// OutEdgeIt(const ResGraphWrapper& resG, Node v) : Edge() { // resG.graph->first(out, v); // while( resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); } // if (!resG.graph->valid(out)) { @@ -1038,7 +1039,7 @@ // class InEdgeIt : public Edge { }; class InEdgeIt { - friend class ResGraphWrapper; + friend class ResGraphWrapper; protected: typename Graph::OutEdgeIt out; typename Graph::InEdgeIt in; @@ -1049,7 +1050,7 @@ // OutEdgeIt(const Edge& e) : Edge(e) { } InEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { } //the unique invalid iterator - InEdgeIt(const ResGraphWrapper& resG, Node v) { + InEdgeIt(const ResGraphWrapper& resG, Node v) { forward=true; resG.graph->first(in, v); while( resG.graph->valid(in) && !(resG.resCap(*this)>0) ) { resG.graph->next(in); } @@ -1072,14 +1073,14 @@ }; class EdgeIt { - friend class ResGraphWrapper; + friend class ResGraphWrapper; protected: typename Graph::EdgeIt e; bool forward; public: EdgeIt() { } EdgeIt(const Invalid& i) : e(i), forward(false) { } - EdgeIt(const ResGraphWrapper& resG) { + EdgeIt(const ResGraphWrapper& resG) { forward=true; resG.graph->first(e); while (resG.graph->valid(e) && !(resG.resCap(*this)>0)) resG.graph->next(e); @@ -1094,13 +1095,13 @@ } }; // class EdgeIt : public Edge { -// friend class ResGraphWrapper; +// friend class ResGraphWrapper; // NodeIt v; // public: // EdgeIt() { } // //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { } // EdgeIt(const Invalid& i) : Edge(i) { } -// EdgeIt(const ResGraphWrapper& resG) : Edge() { +// EdgeIt(const ResGraphWrapper& resG) : Edge() { // resG.graph->first(v); // if (resG.graph->valid(v)) resG.graph->first(out, v); else out=INVALID; // while (resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); } @@ -1317,9 +1318,9 @@ // template class NodeMap : public Graph::NodeMap { // public: -// NodeMap(const ResGraphWrapper& _G) +// NodeMap(const ResGraphWrapper& _G) // : Graph::NodeMap(_G.gw) { } -// NodeMap(const ResGraphWrapper& _G, +// NodeMap(const ResGraphWrapper& _G, // T a) : Graph::NodeMap(_G.gw, a) { } // }; @@ -1337,8 +1338,8 @@ class EdgeMap { typename Graph::EdgeMap forward_map, backward_map; public: - EdgeMap(const ResGraphWrapper& _G) : forward_map(*(_G.graph)), backward_map(*(_G.graph)) { } - EdgeMap(const ResGraphWrapper& _G, T a) : forward_map(*(_G.graph), a), backward_map(*(_G.graph), a) { } + EdgeMap(const ResGraphWrapper& _G) : forward_map(*(_G.graph)), backward_map(*(_G.graph)) { } + EdgeMap(const ResGraphWrapper& _G, T a) : forward_map(*(_G.graph), a), backward_map(*(_G.graph), a) { } void set(Edge e, T a) { if (e.forward) forward_map.set(e.out, a); diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/marci/macro_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/marci/macro_test.cc Thu Apr 15 14:41:20 2004 +0000 @@ -0,0 +1,28 @@ +// -*- c++ -*- +#include +#include + +#include +#include + +using namespace hugo; + +int main() +{ + typedef ListGraph Graph; + Graph g; + Graph::Node n1=g.addNode(); + Graph::Node n2=g.addNode(); + Graph::NodeIt n; + FOR_EACH(n, g) { + std::cout << g.id(n) << " "; + } + std::cout << std::endl; + FOR_EACH_LOC(Graph::NodeIt, m, g) { + std::cout << g.id(m) << " "; + } + std::cout << std::endl; + + + return 0; +} diff -r 0dade87d013b -r 7ac0d4e8a31c src/work/marci/makefile --- a/src/work/marci/makefile Thu Apr 15 08:06:43 2004 +0000 +++ b/src/work/marci/makefile Thu Apr 15 14:41:20 2004 +0000 @@ -12,7 +12,7 @@ CXXFLAGS = -g -O -W -Wall $(INCLUDEDIRS) -ansi -pedantic -ftemplate-depth-30 LEDABINARIES = lg_vs_sg leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo -BINARIES = edmonds_karp_demo iterator_bfs_demo +BINARIES = edmonds_karp_demo iterator_bfs_demo macro_test #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda all: $(BINARIES)