COIN-OR::LEMON - Graph Library

source: lemon-0.x/lemon/bits/erasable_graph_extender.h @ 1965:71b3bc042c47

Last change on this file since 1965:71b3bc042c47 was 1956:a055123339d5, checked in by Alpar Juttner, 18 years ago

Unified copyright notices

File size: 3.2 KB
RevLine 
[1956]1/* -*- C++ -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library
4 *
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
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.
12 *
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
15 * purpose.
16 *
17 */
[946]18
19#ifndef LEMON_ERASABLE_GRAPH_EXTENDER_H
20#define LEMON_ERASABLE_GRAPH_EXTENDER_H
21
[1414]22#include <vector>
23
[946]24#include <lemon/invalid.h>
25
26
27namespace lemon {
28
29  template <typename _Base>
30  class ErasableGraphExtender : public _Base {
31  public:
32
33    typedef ErasableGraphExtender Graph;
34    typedef _Base Parent;
35
36    typedef typename Parent::Node Node;
37    typedef typename Parent::Edge Edge;
38
39    void erase(const Node& node) {
40      Edge edge;
41      Parent::firstOut(edge, node);
42      while (edge != INVALID ) {
43        erase(edge);
44        Parent::firstOut(edge, node);
45      }
46
47      Parent::firstIn(edge, node);
48      while (edge != INVALID ) {
49        erase(edge);
50        Parent::firstIn(edge, node);
51      }
52
[1039]53      Parent::getNotifier(Node()).erase(node);
[946]54      Parent::erase(node);
55    }
56   
57    void erase(const Edge& edge) {
[1039]58      Parent::getNotifier(Edge()).erase(edge);
[946]59      Parent::erase(edge);
60    }
61
62  };
63
[1022]64  template <typename _Base>
[1842]65  class ErasableEdgeSetExtender : public _Base {
66  public:
67
68    typedef ErasableEdgeSetExtender Graph;
69    typedef _Base Parent;
70
71    typedef typename Parent::Edge Edge;
72
73    void erase(const Edge& edge) {
74      Parent::getNotifier(Edge()).erase(edge);
75      Parent::erase(edge);
76    }
77
78  };
79
80  template <typename _Base>
[1909]81  class ErasableUGraphExtender : public _Base {
[1022]82  public:
83
[1909]84    typedef ErasableUGraphExtender Graph;
[1022]85    typedef _Base Parent;
86
87    typedef typename Parent::Node Node;
[1909]88    typedef typename Parent::UEdge UEdge;
[1022]89    typedef typename Parent::Edge Edge;
90
91    void erase(const Node& node) {
92      Edge edge;
93      Parent::firstOut(edge, node);
94      while (edge != INVALID ) {
95        erase(edge);
96        Parent::firstOut(edge, node);
97      }
98
[1039]99      Parent::getNotifier(Node()).erase(node);
[1022]100      Parent::erase(node);
101    }
102   
[1909]103    void erase(const UEdge& uedge) {
[1414]104      std::vector<Edge> edges;
[1627]105      edges.push_back(Parent::direct(uedge,true));
106      edges.push_back(Parent::direct(uedge,false));
[1414]107      Parent::getNotifier(Edge()).erase(edges);
[1909]108      Parent::getNotifier(UEdge()).erase(uedge);
[1022]109      Parent::erase(uedge);
110    }
111
112  };
113
[1842]114  template <typename _Base>
[1909]115  class ErasableUEdgeSetExtender : public _Base {
[1842]116  public:
117
[1909]118    typedef ErasableUEdgeSetExtender Graph;
[1842]119    typedef _Base Parent;
120
121    typedef typename Parent::Node Node;
[1909]122    typedef typename Parent::UEdge UEdge;
[1842]123    typedef typename Parent::Edge Edge;
124
[1909]125    void erase(const UEdge& uedge) {
[1842]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);
[1909]130      Parent::getNotifier(UEdge()).erase(uedge);
[1842]131      Parent::erase(uedge);
132    }
133
134  };
135
[946]136}
137
138#endif
Note: See TracBrowser for help on using the repository browser.