diff -r fe81c4b117f4 -r bf7aea53635a src/work/marci/graph_wrapper.h --- a/src/work/marci/graph_wrapper.h Tue Mar 30 13:18:10 2004 +0000 +++ b/src/work/marci/graph_wrapper.h Tue Mar 30 13:37:21 2004 +0000 @@ -15,27 +15,80 @@ typedef Graph BaseGraph; typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - + class NodeIt : public Graph::NodeIt { + public: + NodeIt() { } + NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { } + NodeIt(const Invalid& i) : Graph::NodeIt(i) { } + NodeIt(const TrivGraphWrapper& _G) : + Graph::NodeIt(*(_G.graph)) { } + }; typedef typename Graph::Edge Edge; - typedef typename Graph::OutEdgeIt OutEdgeIt; - typedef typename Graph::InEdgeIt InEdgeIt; + //typedef typename Graph::OutEdgeIt OutEdgeIt; + class OutEdgeIt : public Graph::OutEdgeIt { + public: + OutEdgeIt() { } + OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { } + OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { } + OutEdgeIt(const TrivGraphWrapper& _G, const Node& n) : + Graph::OutEdgeIt(*(_G.graph), n) { } + }; + //typedef typename Graph::InEdgeIt InEdgeIt; + class InEdgeIt : public Graph::InEdgeIt { + public: + InEdgeIt() { } + InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { } + InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { } + InEdgeIt(const TrivGraphWrapper& _G, const Node& n) : + Graph::InEdgeIt(*(_G.graph), n) { } + }; //typedef typename Graph::SymEdgeIt SymEdgeIt; - typedef typename Graph::EdgeIt EdgeIt; + //typedef typename Graph::EdgeIt EdgeIt; + class EdgeIt : public Graph::EdgeIt { + public: + EdgeIt() { } + EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { } + EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { } + EdgeIt(const TrivGraphWrapper& _G) : + Graph::EdgeIt(*(_G.graph)) { } + }; //TrivGraphWrapper() : graph(0) { } TrivGraphWrapper(Graph& _graph) : graph(&_graph) { } - void setGraph(Graph& _graph) { graph = &_graph; } - Graph& getGraph() const { return (*graph); } +// void setGraph(Graph& _graph) { graph = &_graph; } +// Graph& getGraph() const { return (*graph); } + + NodeIt& first(NodeIt& i) const { + i=NodeIt(*this); + return i; + } + EdgeIt& first(EdgeIt& i) const { + i=EdgeIt(*this); + return i; + } +// template I& first(I& i) const { +// //return graph->first(i); +// i=I(*this); +// return i; +// } + OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { + i=OutEdgeIt(*this, p); + return i; + } + InEdgeIt& first(InEdgeIt& i, const Node& p) const { + i=InEdgeIt(*this, p); + return i; + } +// template I& first(I& i, const P& p) const { +// //return graph->first(i, p); +// i=I(*this, p); +// return i; +// } - template I& first(I& i) const { return graph->first(i); } - template I& first(I& i, const P& p) const { - return graph->first(i, p); } - - template I getNext(const I& i) const { - return graph->getNext(i); } - template I& next(I &i) const { return graph->next(i); } +// template I getNext(const I& i) const { +// return graph->getNext(i); } + template I& next(I &i) const { graph->next(i); return i; } template< typename It > It first() const { It e; first(e); return e; } @@ -71,17 +124,17 @@ template class NodeMap : public Graph::NodeMap { public: NodeMap(const TrivGraphWrapper& _G) : - Graph::NodeMap(_G.getGraph()) { } + Graph::NodeMap(*(_G.graph)) { } NodeMap(const TrivGraphWrapper& _G, T a) : - Graph::NodeMap(_G.getGraph(), a) { } + Graph::NodeMap(*(_G.graph), a) { } }; template class EdgeMap : public Graph::EdgeMap { public: EdgeMap(const TrivGraphWrapper& _G) : - Graph::EdgeMap(_G.getGraph()) { } + Graph::EdgeMap(*(_G.graph)) { } EdgeMap(const TrivGraphWrapper& _G, T a) : - Graph::EdgeMap(_G.getGraph(), a) { } + Graph::EdgeMap(*(_G.graph), a) { } }; }; @@ -93,14 +146,58 @@ public: //typedef typename GraphWrapper::BaseGraph BaseGraph; +// typedef typename GraphWrapper::Node Node; +// typedef typename GraphWrapper::NodeIt NodeIt; + +// typedef typename GraphWrapper::Edge Edge; +// typedef typename GraphWrapper::OutEdgeIt OutEdgeIt; +// typedef typename GraphWrapper::InEdgeIt InEdgeIt; +// //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt; +// typedef typename GraphWrapper::EdgeIt EdgeIt; + typedef typename GraphWrapper::Node Node; - typedef typename GraphWrapper::NodeIt NodeIt; + class NodeIt : public GraphWrapper::NodeIt { + public: + NodeIt() { } + NodeIt(const typename GraphWrapper::NodeIt& n) : + GraphWrapper::NodeIt(n) { } + NodeIt(const Invalid& i) : GraphWrapper::NodeIt(i) { } + NodeIt(const GraphWrapperSkeleton& _G) : + GraphWrapper::NodeIt(_G.gw) { } + }; + typedef typename GraphWrapper::Edge Edge; + //typedef typename GraphWrapper::OutEdgeIt OutEdgeIt; + class OutEdgeIt : public GraphWrapper::OutEdgeIt { + public: + OutEdgeIt() { } + OutEdgeIt(const typename GraphWrapper::OutEdgeIt& e) : + GraphWrapper::OutEdgeIt(e) { } + OutEdgeIt(const Invalid& i) : GraphWrapper::OutEdgeIt(i) { } + OutEdgeIt(const GraphWrapperSkeleton& _G, const Node& n) : + GraphWrapper::OutEdgeIt(_G.gw, n) { } + }; + //typedef typename GraphWrapper::InEdgeIt InEdgeIt; + class InEdgeIt : public GraphWrapper::InEdgeIt { + public: + InEdgeIt() { } + InEdgeIt(const typename GraphWrapper::InEdgeIt& e) : + GraphWrapper::InEdgeIt(e) { } + InEdgeIt(const Invalid& i) : GraphWrapper::InEdgeIt(i) { } + InEdgeIt(const GraphWrapperSkeleton& _G, const Node& n) : + GraphWrapper::InEdgeIt(_G.gw, n) { } + }; + //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt; + //typedef typename GraphWrapper::EdgeIt EdgeIt; + class EdgeIt : public GraphWrapper::EdgeIt { + public: + EdgeIt() { } + EdgeIt(const typename GraphWrapper::EdgeIt& e) : + GraphWrapper::EdgeIt(e) { } + EdgeIt(const Invalid& i) : GraphWrapper::EdgeIt(i) { } + EdgeIt(const GraphWrapperSkeleton& _G) : + GraphWrapper::EdgeIt(_G.gw) { } + }; - typedef typename GraphWrapper::Edge Edge; - typedef typename GraphWrapper::OutEdgeIt OutEdgeIt; - typedef typename GraphWrapper::InEdgeIt InEdgeIt; - //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt; - typedef typename GraphWrapper::EdgeIt EdgeIt; //GraphWrapperSkeleton() : gw() { } GraphWrapperSkeleton(GraphWrapper _gw) : gw(_gw) { } @@ -108,12 +205,17 @@ //void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); } //BaseGraph& getGraph() const { return gw.getGraph(); } - template I& first(I& i) const { return gw.first(i); } + template I& first(I& i) const { + i=I(*this); + return i; + } template I& first(I& i, const P& p) const { - return gw.first(i, p); } + i=I(*this, p); + return i; + } - template I getNext(const I& i) const { return gw.getNext(i); } - template I& next(I &i) const { return gw.next(i); } +// template I getNext(const I& i) const { return gw.getNext(i); } + template I& next(I &i) const { gw.next(i); return i; } template< typename It > It first() const { It e; this->first(e); return e; } @@ -655,9 +757,9 @@ return e; } - template I& first(I& i) const { return gw.first(i); } + template I& first(I& i) const { gw.first(i); return i; } template I& first(I& i, const P& p) const { - return graph->first(i, p); } + graph->first(i, p); return i; } OutEdgeIt& next(OutEdgeIt& e) const { if (e.out_or_in) { @@ -681,7 +783,7 @@ } template I& next(I &i) const { return gw.next(i); } - template I getNext(const I& i) const { return gw.getNext(i); } +// template I getNext(const I& i) const { return gw.getNext(i); } template< typename It > It first() const { It e; first(e); return e; } @@ -813,14 +915,14 @@ class ResGraphWrapper { public: //typedef Graph BaseGraph; - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; + typedef TrivGraphWrapper GraphWrapper; + typedef typename GraphWrapper::Node Node; + typedef typename GraphWrapper::NodeIt NodeIt; private: - typedef typename Graph::OutEdgeIt OldOutEdgeIt; - typedef typename Graph::InEdgeIt OldInEdgeIt; + typedef typename GraphWrapper::OutEdgeIt OldOutEdgeIt; + typedef typename GraphWrapper::InEdgeIt OldInEdgeIt; protected: //const Graph* graph; - typedef TrivGraphWrapper GraphWrapper; GraphWrapper gw; FlowMap* flow; const CapacityMap* capacity; @@ -871,7 +973,7 @@ //FIXME OutEdgeIt(const Edge& e) : Edge(e) { } OutEdgeIt(const Invalid& i) : Edge(i) { } - private: + protected: OutEdgeIt(const ResGraphWrapper& resG, Node v) : Edge() { resG.gw.first(out, v); while( resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); } @@ -905,7 +1007,7 @@ class EdgeIt : public Edge { friend class ResGraphWrapper; - typename Graph::NodeIt v; + NodeIt v; public: EdgeIt() { } //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }