1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/lemon/bits/erasable_graph_extender.h Tue Apr 05 12:30:46 2005 +0000
1.3 @@ -0,0 +1,80 @@
1.4 +// -*- c++ -*-
1.5 +
1.6 +#ifndef LEMON_ERASABLE_GRAPH_EXTENDER_H
1.7 +#define LEMON_ERASABLE_GRAPH_EXTENDER_H
1.8 +
1.9 +#include <lemon/invalid.h>
1.10 +
1.11 +
1.12 +namespace lemon {
1.13 +
1.14 + template <typename _Base>
1.15 + class ErasableGraphExtender : public _Base {
1.16 + public:
1.17 +
1.18 + typedef ErasableGraphExtender Graph;
1.19 + typedef _Base Parent;
1.20 +
1.21 + typedef typename Parent::Node Node;
1.22 + typedef typename Parent::Edge Edge;
1.23 +
1.24 + void erase(const Node& node) {
1.25 + Edge edge;
1.26 + Parent::firstOut(edge, node);
1.27 + while (edge != INVALID ) {
1.28 + erase(edge);
1.29 + Parent::firstOut(edge, node);
1.30 + }
1.31 +
1.32 + Parent::firstIn(edge, node);
1.33 + while (edge != INVALID ) {
1.34 + erase(edge);
1.35 + Parent::firstIn(edge, node);
1.36 + }
1.37 +
1.38 + Parent::getNotifier(Node()).erase(node);
1.39 + Parent::erase(node);
1.40 + }
1.41 +
1.42 + void erase(const Edge& edge) {
1.43 + Parent::getNotifier(Edge()).erase(edge);
1.44 + Parent::erase(edge);
1.45 + }
1.46 +
1.47 + };
1.48 +
1.49 + template <typename _Base>
1.50 + class ErasableUndirGraphExtender : public _Base {
1.51 + public:
1.52 +
1.53 + typedef ErasableUndirGraphExtender Graph;
1.54 + typedef _Base Parent;
1.55 +
1.56 + typedef typename Parent::Node Node;
1.57 + typedef typename Parent::UndirEdge UndirEdge;
1.58 + typedef typename Parent::Edge Edge;
1.59 +
1.60 + void erase(const Node& node) {
1.61 + Edge edge;
1.62 + Parent::firstOut(edge, node);
1.63 + while (edge != INVALID ) {
1.64 + erase(edge);
1.65 + Parent::firstOut(edge, node);
1.66 + }
1.67 +
1.68 + Parent::getNotifier(Node()).erase(node);
1.69 + Parent::erase(node);
1.70 + }
1.71 +
1.72 + void erase(const UndirEdge& uedge) {
1.73 + Parent::getNotifier(Edge()).erase(Edge(uedge,true));
1.74 + Parent::getNotifier(Edge()).erase(Edge(uedge,false));
1.75 + Parent::getNotifier(UndirEdge()).erase(uedge);
1.76 + Parent::erase(uedge);
1.77 + }
1.78 +
1.79 + };
1.80 +
1.81 +}
1.82 +
1.83 +#endif