/* -*- C++ -*- * * This file is a part of LEMON, a generic C++ optimization library * * Copyright (C) 2003-2006 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ #ifndef LEMON_ERASABLE_GRAPH_EXTENDER_H #define LEMON_ERASABLE_GRAPH_EXTENDER_H #include #include namespace lemon { template class ErasableGraphExtender : public _Base { public: typedef ErasableGraphExtender Graph; typedef _Base Parent; typedef typename Parent::Node Node; typedef typename Parent::Edge Edge; void erase(const Node& node) { Edge edge; Parent::firstOut(edge, node); while (edge != INVALID ) { erase(edge); Parent::firstOut(edge, node); } Parent::firstIn(edge, node); while (edge != INVALID ) { erase(edge); Parent::firstIn(edge, node); } Parent::getNotifier(Node()).erase(node); Parent::erase(node); } void erase(const Edge& edge) { Parent::getNotifier(Edge()).erase(edge); Parent::erase(edge); } }; template class ErasableEdgeSetExtender : public _Base { public: typedef ErasableEdgeSetExtender Graph; typedef _Base Parent; typedef typename Parent::Edge Edge; void erase(const Edge& edge) { Parent::getNotifier(Edge()).erase(edge); Parent::erase(edge); } }; template class ErasableUGraphExtender : public _Base { public: typedef ErasableUGraphExtender Graph; typedef _Base Parent; typedef typename Parent::Node Node; typedef typename Parent::UEdge UEdge; typedef typename Parent::Edge Edge; void erase(const Node& node) { Edge edge; Parent::firstOut(edge, node); while (edge != INVALID ) { erase(edge); Parent::firstOut(edge, node); } Parent::getNotifier(Node()).erase(node); Parent::erase(node); } void erase(const UEdge& uedge) { std::vector edges; edges.push_back(Parent::direct(uedge,true)); edges.push_back(Parent::direct(uedge,false)); Parent::getNotifier(Edge()).erase(edges); Parent::getNotifier(UEdge()).erase(uedge); Parent::erase(uedge); } }; template class ErasableUEdgeSetExtender : public _Base { public: typedef ErasableUEdgeSetExtender Graph; typedef _Base Parent; typedef typename Parent::Node Node; typedef typename Parent::UEdge UEdge; typedef typename Parent::Edge Edge; void erase(const UEdge& uedge) { std::vector edges; edges.push_back(Parent::direct(uedge,true)); edges.push_back(Parent::direct(uedge,false)); Parent::getNotifier(Edge()).erase(edges); Parent::getNotifier(UEdge()).erase(uedge); Parent::erase(uedge); } }; } #endif