klao@946: // -*- c++ -*- klao@946: klao@946: #ifndef LEMON_ERASABLE_GRAPH_EXTENDER_H klao@946: #define LEMON_ERASABLE_GRAPH_EXTENDER_H klao@946: deba@1414: #include deba@1414: klao@946: #include klao@946: klao@946: klao@946: namespace lemon { klao@946: klao@946: template klao@946: class ErasableGraphExtender : public _Base { klao@946: public: klao@946: klao@946: typedef ErasableGraphExtender Graph; klao@946: typedef _Base Parent; klao@946: klao@946: typedef typename Parent::Node Node; klao@946: typedef typename Parent::Edge Edge; klao@946: klao@946: void erase(const Node& node) { klao@946: Edge edge; klao@946: Parent::firstOut(edge, node); klao@946: while (edge != INVALID ) { klao@946: erase(edge); klao@946: Parent::firstOut(edge, node); klao@946: } klao@946: klao@946: Parent::firstIn(edge, node); klao@946: while (edge != INVALID ) { klao@946: erase(edge); klao@946: Parent::firstIn(edge, node); klao@946: } klao@946: deba@1039: Parent::getNotifier(Node()).erase(node); klao@946: Parent::erase(node); klao@946: } klao@946: klao@946: void erase(const Edge& edge) { deba@1039: Parent::getNotifier(Edge()).erase(edge); klao@946: Parent::erase(edge); klao@946: } klao@946: klao@946: }; klao@946: klao@1022: template deba@1842: class ErasableEdgeSetExtender : public _Base { deba@1842: public: deba@1842: deba@1842: typedef ErasableEdgeSetExtender Graph; deba@1842: typedef _Base Parent; deba@1842: deba@1842: typedef typename Parent::Edge Edge; deba@1842: deba@1842: void erase(const Edge& edge) { deba@1842: Parent::getNotifier(Edge()).erase(edge); deba@1842: Parent::erase(edge); deba@1842: } deba@1842: deba@1842: }; deba@1842: deba@1842: template klao@1909: class ErasableUGraphExtender : public _Base { klao@1022: public: klao@1022: klao@1909: typedef ErasableUGraphExtender Graph; klao@1022: typedef _Base Parent; klao@1022: klao@1022: typedef typename Parent::Node Node; klao@1909: typedef typename Parent::UEdge UEdge; klao@1022: typedef typename Parent::Edge Edge; klao@1022: klao@1022: void erase(const Node& node) { klao@1022: Edge edge; klao@1022: Parent::firstOut(edge, node); klao@1022: while (edge != INVALID ) { klao@1022: erase(edge); klao@1022: Parent::firstOut(edge, node); klao@1022: } klao@1022: deba@1039: Parent::getNotifier(Node()).erase(node); klao@1022: Parent::erase(node); klao@1022: } klao@1022: klao@1909: void erase(const UEdge& uedge) { deba@1414: std::vector edges; deba@1627: edges.push_back(Parent::direct(uedge,true)); deba@1627: edges.push_back(Parent::direct(uedge,false)); deba@1414: Parent::getNotifier(Edge()).erase(edges); klao@1909: Parent::getNotifier(UEdge()).erase(uedge); klao@1022: Parent::erase(uedge); klao@1022: } klao@1022: klao@1022: }; klao@1022: deba@1842: template klao@1909: class ErasableUEdgeSetExtender : public _Base { deba@1842: public: deba@1842: klao@1909: typedef ErasableUEdgeSetExtender Graph; deba@1842: typedef _Base Parent; deba@1842: deba@1842: typedef typename Parent::Node Node; klao@1909: typedef typename Parent::UEdge UEdge; deba@1842: typedef typename Parent::Edge Edge; deba@1842: klao@1909: void erase(const UEdge& uedge) { deba@1842: std::vector edges; deba@1842: edges.push_back(Parent::direct(uedge,true)); deba@1842: edges.push_back(Parent::direct(uedge,false)); deba@1842: Parent::getNotifier(Edge()).erase(edges); klao@1909: Parent::getNotifier(UEdge()).erase(uedge); deba@1842: Parent::erase(uedge); deba@1842: } deba@1842: deba@1842: }; deba@1842: klao@946: } klao@946: klao@946: #endif