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_EXTENDABLE_GRAPH_EXTENDER_H
20 #define LEMON_EXTENDABLE_GRAPH_EXTENDER_H
24 template <typename _Base>
25 class ExtendableGraphExtender : public _Base {
28 typedef ExtendableGraphExtender Graph;
31 typedef typename Parent::Node Node;
32 typedef typename Parent::Edge Edge;
35 Node node = Parent::addNode();
36 Parent::getNotifier(Node()).add(node);
40 Edge addEdge(const Node& from, const Node& to) {
41 Edge edge = Parent::addEdge(from, to);
42 Parent::getNotifier(Edge()).add(edge);
48 template <typename _Base>
49 class ExtendableEdgeSetExtender : public _Base {
52 typedef ExtendableEdgeSetExtender Graph;
55 typedef typename Parent::Edge Edge;
56 typedef typename Parent::Node Node;
58 Edge addEdge(const Node& from, const Node& to) {
59 Edge edge = Parent::addEdge(from, to);
60 Parent::getNotifier(Edge()).add(edge);
66 template <typename _Base>
67 class ExtendableUGraphExtender : public _Base {
70 typedef ExtendableUGraphExtender Graph;
73 typedef typename Parent::Node Node;
74 typedef typename Parent::Edge Edge;
75 typedef typename Parent::UEdge UEdge;
78 Node node = Parent::addNode();
79 Parent::getNotifier(Node()).add(node);
83 UEdge addEdge(const Node& from, const Node& to) {
84 UEdge uedge = Parent::addEdge(from, to);
85 Parent::getNotifier(UEdge()).add(uedge);
87 std::vector<Edge> edges;
88 edges.push_back(Parent::direct(uedge, true));
89 edges.push_back(Parent::direct(uedge, false));
90 Parent::getNotifier(Edge()).add(edges);
97 template <typename _Base>
98 class ExtendableUEdgeSetExtender : public _Base {
101 typedef ExtendableUEdgeSetExtender Graph;
102 typedef _Base Parent;
104 typedef typename Parent::Node Node;
105 typedef typename Parent::Edge Edge;
106 typedef typename Parent::UEdge UEdge;
108 UEdge addEdge(const Node& from, const Node& to) {
109 UEdge uedge = Parent::addEdge(from, to);
110 Parent::getNotifier(UEdge()).add(uedge);
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);
123 template <typename _Base>
124 class ExtendableBpUGraphExtender : public _Base {
127 typedef _Base Parent;
128 typedef ExtendableBpUGraphExtender Graph;
130 typedef typename Parent::Node Node;
131 typedef typename Parent::BNode BNode;
132 typedef typename Parent::ANode ANode;
133 typedef typename Parent::Edge Edge;
134 typedef typename Parent::UEdge UEdge;
137 Node node = Parent::addANode();
138 Parent::getNotifier(ANode()).add(node);
139 Parent::getNotifier(Node()).add(node);
144 Node node = Parent::addBNode();
145 Parent::getNotifier(BNode()).add(node);
146 Parent::getNotifier(Node()).add(node);
150 UEdge addEdge(const Node& source, const Node& target) {
151 UEdge uedge = Parent::addEdge(source, target);
152 Parent::getNotifier(UEdge()).add(uedge);
154 std::vector<Edge> edges;
155 edges.push_back(Parent::direct(uedge, true));
156 edges.push_back(Parent::direct(uedge, false));
157 Parent::getNotifier(Edge()).add(edges);