diff -r 665ffade9aca -r 89969b303727 src/lemon/graph_wrapper.h --- a/src/lemon/graph_wrapper.h Mon Nov 15 16:39:55 2004 +0000 +++ b/src/lemon/graph_wrapper.h Tue Nov 16 13:03:47 2004 +0000 @@ -1799,6 +1799,68 @@ }; + + template + class ErasingFirstGraphWrapperBase : public GraphWrapperBase<_Graph> { + public: + typedef _Graph Graph; + typedef GraphWrapperBase<_Graph> Parent; + protected: + FirstOutEdgesMap* first_out_edges; + ErasingFirstGraphWrapperBase() : Parent(), + first_out_edges(0) { } + + void setFirstOutEdgesMap(FirstOutEdgesMap& _first_out_edges) { + first_out_edges=&_first_out_edges; + } + + public: + + typedef typename Parent::Node Node; + typedef typename Parent::Edge Edge; + +// using Parent::first; +// void first(Node& i) const { +// Parent::first(i); +// while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); +// } +// void first(Edge& i) const { +// Parent::first(i); +// while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i); +// } +// void firstIn(Edge& i, const Node& n) const { +// Parent::firstIn(i, n); +// while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i); +// } + void firstOut(Edge& i, const Node& n) const { + i=(*first_out_edges)[n]; + } + + void erase(const Edge& e) const { + Node n=source(e); + Edge f=e; + Parent::nextOut(f); + first_out_edges->set(n, f); + } +// void next(Node& i) const { +// Parent::next(i); +// while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); +// } +// void next(Edge& i) const { +// Parent::next(i); +// while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i); +// } +// void nextIn(Edge& i) const { +// Parent::nextIn(i); +// while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i); +// } +// void nextOut(Edge& i) const { +// Parent::nextOut(i); +// while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextOut(i); +// } + }; + + /// For blocking flows. ///\warning Graph wrappers are in even more experimental state than the other @@ -1813,52 +1875,70 @@ /// is called. /// /// \author Marton Makai - template - class ErasingFirstGraphWrapper : public GraphWrapper { + template + class ErasingFirstGraphWrapper : + public IterableGraphExtender< + ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > { public: - typedef GraphWrapper Parent; - protected: - FirstOutEdgesMap* first_out_edges; - public: + typedef _Graph Graph; + typedef IterableGraphExtender< + ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > Parent; ErasingFirstGraphWrapper(Graph& _graph, - FirstOutEdgesMap& _first_out_edges) : - GraphWrapper(_graph), first_out_edges(&_first_out_edges) { } - - typedef typename GraphWrapper::Node Node; - typedef typename GraphWrapper::Edge Edge; - class OutEdgeIt : public Edge { - friend class GraphWrapper; - friend class ErasingFirstGraphWrapper; - const ErasingFirstGraphWrapper* gw; - public: - OutEdgeIt() { } - OutEdgeIt(Invalid i) : Edge(i) { } - OutEdgeIt(const ErasingFirstGraphWrapper& _gw, - const Node& n) : - Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { } - OutEdgeIt(const ErasingFirstGraphWrapper& _gw, - const Edge& e) : - Edge(e), gw(&_gw) { } - OutEdgeIt& operator++() { - *(static_cast(this))= - ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); - return *this; - } - }; - + FirstOutEdgesMap& _first_out_edges) { + setGraph(_graph); + setFirstOutEdgesMap(_first_out_edges); + } // using GraphWrapper::first; // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { // i=OutEdgeIt(*this, p); return i; // } - void erase(const Edge& e) const { - Node n=source(e); - typename Graph::OutEdgeIt f(*Parent::graph, n); - ++f; - first_out_edges->set(n, f); - } + }; +// template +// class ErasingFirstGraphWrapper : public GraphWrapper { +// public: +// typedef GraphWrapper Parent; +// protected: +// FirstOutEdgesMap* first_out_edges; +// public: +// ErasingFirstGraphWrapper(Graph& _graph, +// FirstOutEdgesMap& _first_out_edges) : +// GraphWrapper(_graph), first_out_edges(&_first_out_edges) { } - // KEEP_MAPS(Parent, ErasingFirstGraphWrapper); - }; +// typedef typename GraphWrapper::Node Node; +// typedef typename GraphWrapper::Edge Edge; +// class OutEdgeIt : public Edge { +// friend class GraphWrapper; +// friend class ErasingFirstGraphWrapper; +// const ErasingFirstGraphWrapper* gw; +// public: +// OutEdgeIt() { } +// OutEdgeIt(Invalid i) : Edge(i) { } +// OutEdgeIt(const ErasingFirstGraphWrapper& _gw, +// const Node& n) : +// Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { } +// OutEdgeIt(const ErasingFirstGraphWrapper& _gw, +// const Edge& e) : +// Edge(e), gw(&_gw) { } +// OutEdgeIt& operator++() { +// *(static_cast(this))= +// ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); +// return *this; +// } +// }; + +// // using GraphWrapper::first; +// // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { +// // i=OutEdgeIt(*this, p); return i; +// // } +// void erase(const Edge& e) const { +// Node n=source(e); +// typename Graph::OutEdgeIt f(*Parent::graph, n); +// ++f; +// first_out_edges->set(n, f); +// } + +// // KEEP_MAPS(Parent, ErasingFirstGraphWrapper); +// }; ///@}