marci@76: // -*-mode: c++; -*- marci@76: #ifndef GRAPH_WRAPPER_H marci@76: #define GRAPH_WRAPPER_H marci@76: alpar@105: namespace hugo { marci@76: marci@76: template marci@76: class TrivGraphWrapper { marci@76: Graph* graph; marci@76: marci@76: public: marci@76: typedef Graph BaseGraph; marci@76: marci@76: typedef typename Graph::NodeIt NodeIt; marci@76: typedef typename Graph::EachNodeIt EachNodeIt; marci@76: marci@155: typedef typename Graph::EdgeIt EdgeIt; marci@76: typedef typename Graph::OutEdgeIt OutEdgeIt; marci@76: typedef typename Graph::InEdgeIt InEdgeIt; marci@155: //typedef typename Graph::SymEdgeIt SymEdgeIt; marci@76: typedef typename Graph::EachEdgeIt EachEdgeIt; marci@76: marci@76: template I& getFirst(I& i) const { return graph->getFirst(i); } marci@76: template I& getFirst(I& i, const P& p) const { marci@76: return graph->getFirst(i, p); } marci@155: marci@155: template I getNext(const I& i) const { marci@155: return graph->getNext(i); } marci@155: template I& next(I &i) const { return graph->next(i); } marci@76: marci@76: template< typename It > It first() const { marci@76: It e; getFirst(e); return e; } marci@76: marci@155: template< typename It > It first(const NodeIt& v) const { marci@76: It e; getFirst(e, v); return e; } marci@76: marci@76: NodeIt head(const EdgeIt& e) const { return graph->head(e); } marci@76: NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } marci@155: marci@155: template bool valid(const I& i) const marci@155: { return graph->valid(i); } marci@155: marci@155: //template void setInvalid(const I &i); marci@155: //{ return graph->setInvalid(i); } marci@155: marci@155: int nodeNum() const { return graph->nodeNum(); } marci@155: int edgeNum() const { return graph->edgeNum(); } marci@76: marci@76: template NodeIt aNode(const I& e) const { marci@76: return graph->aNode(e); } marci@76: template NodeIt bNode(const I& e) const { marci@76: return graph->bNode(e); } marci@76: marci@76: NodeIt addNode() const { return graph->addNode(); } marci@76: EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) const { marci@76: return graph->addEdge(tail, head); } marci@76: marci@76: template void erase(const I& i) const { graph->erase(i); } marci@76: marci@76: void clear() const { graph->clear(); } marci@155: marci@76: template class NodeMap : public Graph::NodeMap { marci@76: public: marci@155: NodeMap(const TrivGraphWrapper& _G) : marci@155: Graph::NodeMap(*(_G.G)) { } marci@155: NodeMap(const TrivGraphWrapper& _G, T a) : marci@155: Graph::NodeMap(*(_G.G), a) { } marci@76: }; marci@155: template class EdgeMap : public Graph::EdgeMap { marci@155: public: marci@155: EdgeMap(const TrivGraphWrapper& _G) : marci@155: Graph::EdgeMap(*(_G.G)) { } marci@155: EdgeMap(const TrivGraphWrapper& _G, T a) : marci@155: Graph::EdgeMap(*(_G.G), a) { } marci@155: }; marci@155: marci@76: void setGraph(Graph& _graph) { graph = &_graph; } marci@155: Graph& getGraph() const { return (*graph); } marci@76: marci@76: //TrivGraphWrapper() : graph(0) { } marci@76: TrivGraphWrapper(Graph& _graph) : graph(&_graph) { } marci@76: }; marci@76: marci@76: template marci@76: class RevGraphWrapper marci@76: { marci@76: Graph* graph; marci@76: marci@76: public: marci@76: typedef Graph BaseGraph; marci@76: marci@155: typedef typename Graph::NodeIt NodeIt; marci@76: typedef typename Graph::EachNodeIt EachNodeIt; marci@76: marci@155: typedef typename Graph::EdgeIt EdgeIt; marci@76: typedef typename Graph::OutEdgeIt InEdgeIt; marci@76: typedef typename Graph::InEdgeIt OutEdgeIt; marci@155: //typedef typename Graph::SymEdgeIt SymEdgeIt; marci@76: typedef typename Graph::EachEdgeIt EachEdgeIt; marci@76: marci@76: template I& getFirst(I& i) const { return graph->getFirst(i); } marci@76: template I& getFirst(I& i, const P& p) const { marci@76: return graph->getFirst(i, p); } marci@155: marci@155: template I getNext(const I& i) const { marci@155: return graph->getNext(i); } marci@155: template I& next(I &i) const { return graph->next(i); } marci@76: marci@76: template< typename It > It first() const { marci@76: It e; getFirst(e); return e; } marci@76: marci@155: template< typename It > It first(const NodeIt& v) const { marci@76: It e; getFirst(e, v); return e; } marci@76: marci@76: NodeIt head(const EdgeIt& e) const { return graph->tail(e); } marci@76: NodeIt tail(const EdgeIt& e) const { return graph->head(e); } marci@76: marci@155: template bool valid(const I& i) const marci@155: { return graph->valid(i); } marci@155: marci@155: //template void setInvalid(const I &i); marci@155: //{ return graph->setInvalid(i); } marci@155: marci@76: template NodeIt aNode(const I& e) const { marci@76: return graph->aNode(e); } marci@76: template NodeIt bNode(const I& e) const { marci@76: return graph->bNode(e); } marci@155: marci@155: NodeIt addNode() const { return graph->addNode(); } marci@155: EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) const { marci@76: return graph->addEdge(tail, head); } marci@76: marci@155: int nodeNum() const { return graph->nodeNum(); } marci@155: int edgeNum() const { return graph->edgeNum(); } marci@76: marci@155: template void erase(const I& i) const { graph->erase(i); } marci@76: marci@155: void clear() const { graph->clear(); } marci@155: marci@155: template class NodeMap : public Graph::NodeMap { marci@155: public: marci@155: NodeMap(const RevGraphWrapper& _G) : marci@155: Graph::NodeMap(*(_G.G)) { } marci@155: NodeMap(const RevGraphWrapper& _G, T a) : marci@155: Graph::NodeMap(*(_G.G), a) { } marci@155: }; marci@155: template class EdgeMap : public Graph::EdgeMap { marci@155: public: marci@155: EdgeMap(const RevGraphWrapper& _G) : marci@155: Graph::EdgeMap(*(_G.G)) { } marci@155: EdgeMap(const RevGraphWrapper& _G, T a) : marci@155: Graph::EdgeMap(*(_G.G), a) { } marci@155: }; marci@155: marci@76: void setGraph(Graph& _graph) { graph = &_graph; } marci@155: Graph& getGraph() const { return (*graph); } marci@76: marci@76: //RevGraphWrapper() : graph(0) { } marci@76: RevGraphWrapper(Graph& _graph) : graph(&_graph) { } marci@76: }; marci@76: marci@155: marci@155: // template marci@155: // class SymGraphWrapper marci@155: // { marci@155: // Graph* graph; marci@76: marci@155: // public: marci@155: // typedef Graph BaseGraph; marci@155: marci@155: // typedef typename Graph::NodeIt NodeIt; marci@155: // typedef typename Graph::EdgeIt EdgeIt; marci@155: marci@155: // typedef typename Graph::EachNodeIt EachNodeIt; marci@155: marci@155: // //FIXME tag-ekkel megcsinalni, hogy abbol csinaljon marci@155: // //iranyitatlant, ami van marci@155: // //mert csak 1 dolgot lehet be typedef-elni marci@155: // typedef typename Graph::OutEdgeIt SymEdgeIt; marci@155: // //typedef typename Graph::InEdgeIt SymEdgeIt; marci@155: // //typedef typename Graph::SymEdgeIt SymEdgeIt; marci@155: // typedef typename Graph::EachEdgeIt EachEdgeIt; marci@155: marci@155: // int nodeNum() const { return graph->nodeNum(); } marci@155: // int edgeNum() const { return graph->edgeNum(); } marci@155: marci@155: // template I& getFirst(I& i) const { return graph->getFirst(i); } marci@155: // template I& getFirst(I& i, const P& p) const { marci@155: // return graph->getFirst(i, p); } marci@155: // //template I next(const I i); { return graph->goNext(i); } marci@155: // //template I &goNext(I &i); { return graph->goNext(i); } marci@155: marci@155: // template< typename It > It first() const { marci@155: // It e; getFirst(e); return e; } marci@155: marci@155: // template< typename It > It first(NodeIt v) const { marci@155: // It e; getFirst(e, v); return e; } marci@155: marci@155: // NodeIt head(const EdgeIt& e) const { return graph->head(e); } marci@155: // NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } marci@155: marci@155: // template NodeIt aNode(const I& e) const { marci@155: // return graph->aNode(e); } marci@155: // template NodeIt bNode(const I& e) const { marci@155: // return graph->bNode(e); } marci@155: marci@155: // //template bool valid(const I i); marci@155: // //{ return graph->valid(i); } marci@155: marci@155: // //template void setInvalid(const I &i); marci@155: // //{ return graph->setInvalid(i); } marci@155: marci@155: // NodeIt addNode() { return graph->addNode(); } marci@155: // EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { marci@155: // return graph->addEdge(tail, head); } marci@155: marci@155: // template void erase(const I& i) { graph->erase(i); } marci@155: marci@155: // void clear() { graph->clear(); } marci@155: marci@155: // template class NodeMap : public Graph::NodeMap { }; marci@155: // template class EdgeMap : public Graph::EdgeMap { }; marci@155: marci@155: // void setGraph(Graph& _graph) { graph = &_graph; } marci@155: // Graph& getGraph() { return (*graph); } marci@155: marci@155: // //SymGraphWrapper() : graph(0) { } marci@155: // SymGraphWrapper(Graph& _graph) : graph(&_graph) { } marci@155: // }; marci@155: marci@155: marci@155: template marci@155: class ResGraphWrapper { marci@76: public: marci@76: typedef Graph BaseGraph; marci@155: typedef typename Graph::NodeIt NodeIt; marci@155: typedef typename Graph::EachNodeIt EachNodeIt; marci@155: private: marci@155: typedef typename Graph::OutEdgeIt OldOutEdgeIt; marci@155: typedef typename Graph::InEdgeIt OldInEdgeIt; marci@155: const Graph* G; marci@155: FlowMap* flow; marci@155: const CapacityMap* capacity; marci@155: public: marci@155: ResGraphWrapper(const Graph& _G, FlowMap& _flow, marci@155: const CapacityMap& _capacity) : marci@155: G(&_G), flow(&_flow), capacity(&_capacity) { } marci@155: // ResGraphWrapper(const ResGraphWrapper& res_graph_wrapper) : marci@155: // G(res_graph_wrapper.G), flow(res_graph_wrapper.flow), capacity(res_graph_wrapper.capacity) { } marci@155: class EdgeIt; marci@155: class OutEdgeIt; marci@155: friend class EdgeIt; marci@155: friend class OutEdgeIt; marci@76: marci@155: class EdgeIt { marci@155: friend class ResGraphWrapper; marci@155: protected: marci@155: //const ResGraph3* resG; marci@155: const Graph* G; marci@155: FlowMap* flow; marci@155: const CapacityMap* capacity; marci@155: //OldSymEdgeIt sym; marci@155: OldOutEdgeIt out; marci@155: OldInEdgeIt in; marci@155: bool out_or_in; //true, iff out marci@155: public: marci@155: EdgeIt() : out_or_in(true) { } marci@155: EdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) : marci@155: G(&_G), flow(&_flow), capacity(&_capacity), out_or_in(true) { } marci@155: //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) { } marci@155: Number free() const { marci@155: if (out_or_in) { marci@155: return (/*resG->*/capacity->get(out)-/*resG->*/flow->get(out)); marci@155: } else { marci@155: return (/*resG->*/flow->get(in)); marci@155: } marci@155: } marci@155: bool valid() const { marci@155: return out_or_in && out.valid() || in.valid(); } marci@155: void augment(Number a) const { marci@155: if (out_or_in) { marci@155: /*resG->*/flow->set(out, /*resG->*/flow->get(out)+a); marci@155: } else { marci@155: /*resG->*/flow->set(in, /*resG->*/flow->get(in)-a); marci@155: } marci@155: } marci@155: void print() { marci@155: if (out_or_in) { marci@155: std::cout << "out "; marci@155: if (out.valid()) marci@155: std::cout << G->id(G->tail(out)) << "--"<< G->id(out) <<"->"<< G->id(G->head(out)); marci@155: else marci@155: std::cout << "invalid"; marci@155: } marci@155: else { marci@155: std::cout << "in "; marci@155: if (in.valid()) marci@155: std::cout << G->id(G->head(in)) << "<-"<< G->id(in) <<"--"<< G->id(G->tail(in)); marci@155: else marci@155: std::cout << "invalid"; marci@155: } marci@155: std::cout << std::endl; marci@155: } marci@155: }; marci@155: marci@155: Number free(OldOutEdgeIt out) const { marci@155: return (/*resG->*/capacity->get(out)-/*resG->*/flow->get(out)); marci@155: } marci@155: Number free(OldInEdgeIt in) const { marci@155: return (/*resG->*/flow->get(in)); marci@155: } marci@155: marci@155: class OutEdgeIt : public EdgeIt { marci@155: friend class ResGraphWrapper; marci@155: public: marci@155: OutEdgeIt() { } marci@155: private: marci@155: OutEdgeIt(const Graph& _G, NodeIt v, FlowMap& _flow, const CapacityMap& _capacity) : EdgeIt(_G, _flow, _capacity) { marci@155: //out=/*resG->*/G->template first(v); marci@155: G->getFirst(out, v); marci@155: while( out.valid() && !(EdgeIt::free()>0) ) { ++out; } marci@155: if (!out.valid()) { marci@155: out_or_in=0; marci@155: //in=/*resG->*/G->template first(v); marci@155: G->getFirst(in, v); marci@155: while( in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: } marci@155: } marci@155: public: marci@155: OutEdgeIt& operator++() { marci@155: if (out_or_in) { marci@155: NodeIt v=/*resG->*/G->aNode(out); marci@155: ++out; marci@155: while( out.valid() && !(EdgeIt::free()>0) ) { ++out; } marci@155: if (!out.valid()) { marci@155: out_or_in=0; marci@155: G->getFirst(in, v); //=/*resG->*/G->template first(v); marci@155: while( in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: } marci@155: } else { marci@155: ++in; marci@155: while( in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: } marci@155: return *this; marci@155: } marci@155: }; marci@155: marci@155: class EachEdgeIt : public EdgeIt { marci@155: friend class ResGraphWrapper; marci@155: typename Graph::EachNodeIt v; marci@155: public: marci@155: EachEdgeIt() { } marci@155: //EachEdgeIt(const EachEdgeIt& e) : EdgeIt(e), v(e.v) { } marci@155: EachEdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) : EdgeIt(_G, _flow, _capacity) { marci@155: out_or_in=true; marci@155: G->getFirst(v); marci@155: if (v.valid()) G->getFirst(out, v); else out=OldOutEdgeIt(); marci@155: while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } marci@155: while (v.valid() && !out.valid()) { marci@155: ++v; marci@155: if (v.valid()) G->getFirst(out, v); marci@155: while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } marci@155: } marci@155: if (!out.valid()) { marci@155: out_or_in=0; marci@155: G->getFirst(v); marci@155: if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt(); marci@155: while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: while (v.valid() && !in.valid()) { marci@155: ++v; marci@155: if (v.valid()) G->getFirst(in, v); marci@155: while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: } marci@155: } marci@155: } marci@155: EachEdgeIt& operator++() { marci@155: if (out_or_in) { marci@155: ++out; marci@155: while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } marci@155: while (v.valid() && !out.valid()) { marci@155: ++v; marci@155: if (v.valid()) G->getFirst(out, v); marci@155: while (out.valid() && !(EdgeIt::free()>0) ) { ++out; } marci@155: } marci@155: if (!out.valid()) { marci@155: out_or_in=0; marci@155: G->getFirst(v); marci@155: if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt(); marci@155: while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: while (v.valid() && !in.valid()) { marci@155: ++v; marci@155: if (v.valid()) G->getFirst(in, v); marci@155: while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: } marci@155: } marci@155: } else { marci@155: ++in; marci@155: while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: while (v.valid() && !in.valid()) { marci@155: ++v; marci@155: if (v.valid()) G->getFirst(in, v); marci@155: while (in.valid() && !(EdgeIt::free()>0) ) { ++in; } marci@155: } marci@155: } marci@155: return *this; marci@155: } marci@155: }; marci@155: marci@155: void getFirst(EachNodeIt& v) const { G->getFirst(v); } marci@155: void getFirst(OutEdgeIt& e, NodeIt v) const { marci@155: e=OutEdgeIt(*G, v, *flow, *capacity); marci@155: } marci@155: void getFirst(EachEdgeIt& e) const { marci@155: e=EachEdgeIt(*G, *flow, *capacity); marci@155: } marci@155: marci@155: EachNodeIt& next(EachNodeIt& n) const { return G->next(n); } marci@155: marci@155: OutEdgeIt& next(OutEdgeIt& e) const { marci@155: if (e.out_or_in) { marci@155: NodeIt v=G->aNode(e.out); marci@155: ++(e.out); marci@155: while( G->valid(e.out) && !(e.free()>0) ) { ++(e.out); } marci@155: if (!G->valid(e.out)) { marci@155: e.out_or_in=0; marci@155: G->getFirst(e.in, v); //=/*resG->*/G->template first(v); marci@155: while( G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } marci@155: } marci@155: } else { marci@155: ++(e.in); marci@155: while( G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } marci@155: } marci@155: return e; marci@155: } marci@155: marci@155: EachEdgeIt& next(EachEdgeIt& e) const { marci@155: if (e.out_or_in) { marci@155: ++(e.out); marci@155: while (G->valid(e.out) && !(e.free()>0) ) { ++(e.out); } marci@155: while (G->valid(e.v) && !G->valid(e.out)) { marci@155: ++(e.v); marci@155: if (G->valid(e.v)) G->getFirst(e.out, e.v); marci@155: while (G->valid(e.out) && !(e.free()>0) ) { ++(e.out); } marci@155: } marci@155: if (!G->valid(e.out)) { marci@155: e.out_or_in=0; marci@155: G->getFirst(e.v); marci@155: if (G->valid(e.v)) G->getFirst(e.in, e.v); else e.in=OldInEdgeIt(); marci@155: while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } marci@155: while (G->valid(e.v) && !G->valid(e.in)) { marci@155: ++(e.v); marci@155: if (G->valid(e.v)) G->getFirst(e.in, e.v); marci@155: while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } marci@155: } marci@155: } marci@155: } else { marci@155: ++(e.in); marci@155: while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } marci@155: while (G->valid(e.v) && !G->valid(e.in)) { marci@155: ++(e.v); marci@155: if (G->valid(e.v)) G->getFirst(e.in, e.v); marci@155: while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } marci@155: } marci@155: } marci@155: return e; marci@155: } marci@76: marci@76: marci@155: template< typename It > marci@155: It first() const { marci@155: It e; marci@155: getFirst(e); marci@155: return e; marci@155: } marci@76: marci@155: template< typename It > marci@155: It first(NodeIt v) const { marci@155: It e; marci@155: getFirst(e, v); marci@155: return e; marci@155: } marci@76: marci@155: NodeIt tail(EdgeIt e) const { marci@155: return ((e.out_or_in) ? G->aNode(e.out) : G->aNode(e.in)); } marci@155: NodeIt head(EdgeIt e) const { marci@155: return ((e.out_or_in) ? G->bNode(e.out) : G->bNode(e.in)); } marci@76: marci@155: NodeIt aNode(OutEdgeIt e) const { marci@155: return ((e.out_or_in) ? G->aNode(e.out) : G->aNode(e.in)); } marci@155: NodeIt bNode(OutEdgeIt e) const { marci@155: return ((e.out_or_in) ? G->bNode(e.out) : G->bNode(e.in)); } marci@76: marci@155: int id(NodeIt v) const { return G->id(v); } marci@155: marci@155: bool valid(NodeIt n) const { return G->valid(n); } marci@155: bool valid(EdgeIt e) const { marci@155: return e.out_or_in ? G->valid(e.out) : G->valid(e.in); } marci@155: marci@155: template class NodeMap : public Graph::NodeMap { marci@155: public: marci@155: NodeMap(const ResGraphWrapper& _G) marci@155: : Graph::NodeMap(*(_G.G)) { } marci@155: NodeMap(const ResGraphWrapper& _G, marci@155: T a) : Graph::NodeMap(*(_G.G), a) { } marci@155: }; marci@155: marci@155: // template marci@155: // class NodeMap { marci@155: // typename Graph::NodeMap node_map; marci@155: // public: marci@155: // NodeMap(const ResGraphWrapper& _G) : node_map(*(_G.G)) { } marci@155: // NodeMap(const ResGraphWrapper& _G, T a) : node_map(*(_G.G), a) { } marci@155: // void set(NodeIt nit, T a) { node_map.set(nit, a); } marci@155: // T get(NodeIt nit) const { return node_map.get(nit); } marci@155: // }; marci@155: marci@155: template marci@155: class EdgeMap { marci@155: typename Graph::EdgeMap forward_map, backward_map; marci@155: public: marci@155: EdgeMap(const ResGraphWrapper& _G) : forward_map(*(_G.G)), backward_map(*(_G.G)) { } marci@155: EdgeMap(const ResGraphWrapper& _G, T a) : forward_map(*(_G.G), a), backward_map(*(_G.G), a) { } marci@155: void set(EdgeIt e, T a) { marci@155: if (e.out_or_in) marci@155: forward_map.set(e.out, a); marci@155: else marci@155: backward_map.set(e.in, a); marci@155: } marci@155: T get(EdgeIt e) { marci@155: if (e.out_or_in) marci@155: return forward_map.get(e.out); marci@155: else marci@155: return backward_map.get(e.in); marci@155: } marci@155: }; marci@155: marci@76: }; marci@76: marci@76: marci@148: marci@148: // // FIXME: comparison should be made better!!! marci@148: // template marci@148: // class ResGraphWrapper marci@148: // { marci@148: // Graph* graph; marci@76: marci@148: // public: marci@148: // typedef Graph BaseGraph; marci@76: marci@148: // typedef typename Graph::NodeIt NodeIt; marci@148: // typedef typename Graph::EdgeIt EdgeIt; marci@76: marci@148: // typedef typename Graph::EachNodeIt EachNodeIt; marci@76: marci@148: // class OutEdgeIt { marci@148: // public: marci@148: // //Graph::NodeIt n; marci@148: // bool out_or_in; marci@148: // typename Graph::OutEdgeIt o; marci@148: // typename Graph::InEdgeIt i; marci@148: // }; marci@148: // class InEdgeIt { marci@148: // public: marci@148: // //Graph::NodeIt n; marci@148: // bool out_or_in; marci@148: // typename Graph::OutEdgeIt o; marci@148: // typename Graph::InEdgeIt i; marci@148: // }; marci@148: // typedef typename Graph::SymEdgeIt SymEdgeIt; marci@148: // typedef typename Graph::EachEdgeIt EachEdgeIt; marci@76: marci@148: // int nodeNum() const { return graph->nodeNum(); } marci@148: // int edgeNum() const { return graph->edgeNum(); } marci@76: marci@148: // NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); } marci@76: marci@148: // // EachEdge and SymEdge is missing!!!! marci@148: // // EdgeIt <-> In/OutEdgeIt conversion is missing!!!! marci@76: marci@148: // //FIXME marci@148: // OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const marci@148: // { marci@148: // e.n=n; marci@148: // graph->getFirst(e.o,n); marci@148: // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) marci@148: // graph->goNext(e.o); marci@148: // if(!graph->valid(e.o)) { marci@148: // graph->getFirst(e.i,n); marci@148: // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) marci@148: // graph->goNext(e.i); marci@148: // } marci@148: // return e; marci@148: // } marci@148: // /* marci@148: // OutEdgeIt &goNext(OutEdgeIt &e) marci@148: // { marci@148: // if(graph->valid(e.o)) { marci@148: // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) marci@148: // graph->goNext(e.o); marci@148: // if(graph->valid(e.o)) return e; marci@148: // else graph->getFirst(e.i,e.n); marci@148: // } marci@148: // else { marci@148: // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) marci@148: // graph->goNext(e.i); marci@148: // return e; marci@148: // } marci@148: // } marci@148: // OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} marci@148: // */ marci@148: // //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} marci@76: marci@148: // //FIXME marci@148: // InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const marci@148: // { marci@148: // e.n=n; marci@148: // graph->getFirst(e.i,n); marci@148: // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) marci@148: // graph->goNext(e.i); marci@148: // if(!graph->valid(e.i)) { marci@148: // graph->getFirst(e.o,n); marci@148: // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) marci@148: // graph->goNext(e.o); marci@148: // } marci@148: // return e; marci@148: // } marci@148: // /* marci@148: // InEdgeIt &goNext(InEdgeIt &e) marci@148: // { marci@148: // if(graph->valid(e.i)) { marci@148: // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) marci@148: // graph->goNext(e.i); marci@148: // if(graph->valid(e.i)) return e; marci@148: // else graph->getFirst(e.o,e.n); marci@148: // } marci@148: // else { marci@148: // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) marci@148: // graph->goNext(e.o); marci@148: // return e; marci@148: // } marci@148: // } marci@148: // InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} marci@148: // */ marci@148: // //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} marci@76: marci@148: // //template I &goNext(I &i); { return graph->goNext(i); } marci@148: // //template I next(const I i); { return graph->goNext(i); } marci@76: marci@148: // template< typename It > It first() const { marci@148: // It e; getFirst(e); return e; } marci@76: marci@148: // template< typename It > It first(NodeIt v) const { marci@148: // It e; getFirst(e, v); return e; } marci@76: marci@148: // NodeIt head(const EdgeIt& e) const { return graph->head(e); } marci@148: // NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } marci@76: marci@148: // template NodeIt aNode(const I& e) const { marci@148: // return graph->aNode(e); } marci@148: // template NodeIt bNode(const I& e) const { marci@148: // return graph->bNode(e); } marci@76: marci@148: // //template bool valid(const I i); marci@148: // //{ return graph->valid(i); } marci@76: marci@148: // //template void setInvalid(const I &i); marci@148: // //{ return graph->setInvalid(i); } marci@76: marci@148: // NodeIt addNode() { return graph->addNode(); } marci@148: // EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { marci@148: // return graph->addEdge(tail, head); } marci@76: marci@148: // template void erase(const I& i) { graph->erase(i); } marci@76: marci@148: // void clear() { graph->clear(); } marci@76: marci@148: // template class NodeMap : public Graph::NodeMap { }; marci@148: // template class EdgeMap : public Graph::EdgeMap { }; marci@76: marci@148: // void setGraph(Graph& _graph) { graph = &_graph; } marci@148: // Graph& getGraph() { return (*graph); } marci@76: marci@148: // //ResGraphWrapper() : graph(0) { } marci@148: // ResGraphWrapper(Graph& _graph) : graph(&_graph) { } marci@148: // }; marci@76: alpar@105: } //namespace hugo marci@76: marci@76: #endif //GRAPH_WRAPPER_H marci@76: