COIN-OR::LEMON - Graph Library

source: lemon-0.x/lemon/bits/extendable_graph_extender.h @ 1956:a055123339d5

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

Unified copyright notices

File size: 4.1 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_EXTENDABLE_GRAPH_EXTENDER_H
20#define LEMON_EXTENDABLE_GRAPH_EXTENDER_H
21
22namespace lemon {
23
24  template <typename _Base>
25  class ExtendableGraphExtender : public _Base {
26  public:
27
28    typedef ExtendableGraphExtender Graph;
29    typedef _Base Parent;
30
31    typedef typename Parent::Node Node;
32    typedef typename Parent::Edge Edge;
33
34    Node addNode() {
35      Node node = Parent::addNode();
[1039]36      Parent::getNotifier(Node()).add(node);
[946]37      return node;
38    }
39   
40    Edge addEdge(const Node& from, const Node& to) {
41      Edge edge = Parent::addEdge(from, to);
[1039]42      Parent::getNotifier(Edge()).add(edge);
[946]43      return edge;
44    }
45
46  };
47
[1022]48  template <typename _Base>
[1842]49  class ExtendableEdgeSetExtender : public _Base {
50  public:
51
52    typedef ExtendableEdgeSetExtender Graph;
53    typedef _Base Parent;
54
55    typedef typename Parent::Edge Edge;
56    typedef typename Parent::Node Node;
57
58    Edge addEdge(const Node& from, const Node& to) {
59      Edge edge = Parent::addEdge(from, to);
60      Parent::getNotifier(Edge()).add(edge);
61      return edge;
62    }
63
64  };
65
66  template <typename _Base>
[1909]67  class ExtendableUGraphExtender : public _Base {
[1022]68  public:
69
[1909]70    typedef ExtendableUGraphExtender Graph;
[1022]71    typedef _Base Parent;
72
73    typedef typename Parent::Node Node;
74    typedef typename Parent::Edge Edge;
[1909]75    typedef typename Parent::UEdge UEdge;
[1022]76
77    Node addNode() {
78      Node node = Parent::addNode();
[1039]79      Parent::getNotifier(Node()).add(node);
[1022]80      return node;
81    }
82
[1909]83    UEdge addEdge(const Node& from, const Node& to) {
84      UEdge uedge = Parent::addEdge(from, to);
85      Parent::getNotifier(UEdge()).add(uedge);
[1022]86
[1414]87      std::vector<Edge> edges;
[1627]88      edges.push_back(Parent::direct(uedge, true));
89      edges.push_back(Parent::direct(uedge, false));
[1414]90      Parent::getNotifier(Edge()).add(edges);
[1022]91
92      return uedge;
93    }
94
95  };
96
[1842]97  template <typename _Base>
[1909]98  class ExtendableUEdgeSetExtender : public _Base {
[1842]99  public:
100
[1909]101    typedef ExtendableUEdgeSetExtender Graph;
[1842]102    typedef _Base Parent;
103
104    typedef typename Parent::Node Node;
105    typedef typename Parent::Edge Edge;
[1909]106    typedef typename Parent::UEdge UEdge;
[1842]107
[1909]108    UEdge addEdge(const Node& from, const Node& to) {
109      UEdge uedge = Parent::addEdge(from, to);
110      Parent::getNotifier(UEdge()).add(uedge);
[1842]111
112      std::vector<Edge> edges;
113      edges.push_back(Parent::direct(uedge, true));
114      edges.push_back(Parent::direct(uedge, false));
115      Parent::getNotifier(Edge()).add(edges);
116
117      return uedge;
118    }
119
120  };
121
[1820]122
123  template <typename _Base>
[1910]124  class ExtendableBpUGraphExtender : public _Base {
[1820]125  public:
126
127    typedef _Base Parent;
[1910]128    typedef ExtendableBpUGraphExtender Graph;
[1820]129 
130    typedef typename Parent::Node Node;
[1910]131    typedef typename Parent::BNode BNode;
132    typedef typename Parent::ANode ANode;
[1820]133    typedef typename Parent::Edge Edge;
[1909]134    typedef typename Parent::UEdge UEdge;
[1820]135 
[1910]136    Node addANode() {
137      Node node = Parent::addANode();
138      Parent::getNotifier(ANode()).add(node);
[1820]139      Parent::getNotifier(Node()).add(node);
140      return node;
141    }
142
[1910]143    Node addBNode() {
144      Node node = Parent::addBNode();
145      Parent::getNotifier(BNode()).add(node);
[1820]146      Parent::getNotifier(Node()).add(node);
147      return node;
148    }
149 
[1909]150    UEdge addEdge(const Node& source, const Node& target) {
151      UEdge uedge = Parent::addEdge(source, target);
152      Parent::getNotifier(UEdge()).add(uedge);
[1820]153   
154      std::vector<Edge> edges;
[1909]155      edges.push_back(Parent::direct(uedge, true));
156      edges.push_back(Parent::direct(uedge, false));
[1820]157      Parent::getNotifier(Edge()).add(edges);
158   
[1909]159      return uedge;
[1820]160    }
161
162  };
163
[946]164}
165
166#endif
Note: See TracBrowser for help on using the repository browser.