3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_ERASABLE_GRAPH_EXTENDER_H
20 #define LEMON_ERASABLE_GRAPH_EXTENDER_H
24 #include <lemon/invalid.h>
29 template <typename _Base>
30 class ErasableGraphExtender : public _Base {
33 typedef ErasableGraphExtender Graph;
36 typedef typename Parent::Node Node;
37 typedef typename Parent::Edge Edge;
39 void erase(const Node& node) {
41 Parent::firstOut(edge, node);
42 while (edge != INVALID ) {
44 Parent::firstOut(edge, node);
47 Parent::firstIn(edge, node);
48 while (edge != INVALID ) {
50 Parent::firstIn(edge, node);
53 Parent::getNotifier(Node()).erase(node);
57 void erase(const Edge& edge) {
58 Parent::getNotifier(Edge()).erase(edge);
64 template <typename _Base>
65 class ErasableEdgeSetExtender : public _Base {
68 typedef ErasableEdgeSetExtender Graph;
71 typedef typename Parent::Edge Edge;
73 void erase(const Edge& edge) {
74 Parent::getNotifier(Edge()).erase(edge);
80 template <typename _Base>
81 class ErasableUGraphExtender : public _Base {
84 typedef ErasableUGraphExtender Graph;
87 typedef typename Parent::Node Node;
88 typedef typename Parent::UEdge UEdge;
89 typedef typename Parent::Edge Edge;
91 void erase(const Node& node) {
93 Parent::firstOut(edge, node);
94 while (edge != INVALID ) {
96 Parent::firstOut(edge, node);
99 Parent::getNotifier(Node()).erase(node);
103 void erase(const UEdge& uedge) {
104 std::vector<Edge> edges;
105 edges.push_back(Parent::direct(uedge,true));
106 edges.push_back(Parent::direct(uedge,false));
107 Parent::getNotifier(Edge()).erase(edges);
108 Parent::getNotifier(UEdge()).erase(uedge);
109 Parent::erase(uedge);
114 template <typename _Base>
115 class ErasableUEdgeSetExtender : public _Base {
118 typedef ErasableUEdgeSetExtender Graph;
119 typedef _Base Parent;
121 typedef typename Parent::Node Node;
122 typedef typename Parent::UEdge UEdge;
123 typedef typename Parent::Edge Edge;
125 void erase(const UEdge& uedge) {
126 std::vector<Edge> edges;
127 edges.push_back(Parent::direct(uedge,true));
128 edges.push_back(Parent::direct(uedge,false));
129 Parent::getNotifier(Edge()).erase(edges);
130 Parent::getNotifier(UEdge()).erase(uedge);
131 Parent::erase(uedge);