alpar@209
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
deba@57
|
2 |
*
|
alpar@209
|
3 |
* This file is a part of LEMON, a generic C++ optimization library.
|
deba@57
|
4 |
*
|
alpar@877
|
5 |
* Copyright (C) 2003-2010
|
deba@57
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
deba@57
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
deba@57
|
8 |
*
|
deba@57
|
9 |
* Permission to use, modify and distribute this software is granted
|
deba@57
|
10 |
* provided that this copyright notice appears in all copies. For
|
deba@57
|
11 |
* precise terms see the accompanying LICENSE file.
|
deba@57
|
12 |
*
|
deba@57
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
deba@57
|
14 |
* express or implied, and with no claim as to its suitability for any
|
deba@57
|
15 |
* purpose.
|
deba@57
|
16 |
*
|
deba@57
|
17 |
*/
|
deba@57
|
18 |
|
deba@57
|
19 |
///\ingroup graph_concepts
|
deba@57
|
20 |
///\file
|
kpeter@786
|
21 |
///\brief The concepts of graph components.
|
deba@57
|
22 |
|
deba@529
|
23 |
#ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H
|
deba@529
|
24 |
#define LEMON_CONCEPTS_GRAPH_COMPONENTS_H
|
deba@57
|
25 |
|
deba@220
|
26 |
#include <lemon/core.h>
|
deba@57
|
27 |
#include <lemon/concepts/maps.h>
|
deba@57
|
28 |
|
deba@57
|
29 |
#include <lemon/bits/alteration_notifier.h>
|
deba@57
|
30 |
|
deba@57
|
31 |
namespace lemon {
|
deba@57
|
32 |
namespace concepts {
|
deba@57
|
33 |
|
kpeter@579
|
34 |
/// \brief Concept class for \c Node, \c Arc and \c Edge types.
|
deba@57
|
35 |
///
|
kpeter@579
|
36 |
/// This class describes the concept of \c Node, \c Arc and \c Edge
|
kpeter@579
|
37 |
/// subtypes of digraph and graph types.
|
deba@57
|
38 |
///
|
deba@57
|
39 |
/// \note This class is a template class so that we can use it to
|
kpeter@579
|
40 |
/// create graph skeleton classes. The reason for this is that \c Node
|
alpar@877
|
41 |
/// and \c Arc (or \c Edge) types should \e not derive from the same
|
kpeter@579
|
42 |
/// base class. For \c Node you should instantiate it with character
|
kpeter@579
|
43 |
/// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'.
|
deba@57
|
44 |
#ifndef DOXYGEN
|
kpeter@559
|
45 |
template <char sel = '0'>
|
deba@57
|
46 |
#endif
|
deba@57
|
47 |
class GraphItem {
|
deba@57
|
48 |
public:
|
deba@57
|
49 |
/// \brief Default constructor.
|
alpar@209
|
50 |
///
|
kpeter@579
|
51 |
/// Default constructor.
|
deba@57
|
52 |
/// \warning The default constructor is not required to set
|
deba@57
|
53 |
/// the item to some well-defined value. So you should consider it
|
deba@57
|
54 |
/// as uninitialized.
|
deba@57
|
55 |
GraphItem() {}
|
kpeter@579
|
56 |
|
deba@57
|
57 |
/// \brief Copy constructor.
|
deba@57
|
58 |
///
|
deba@57
|
59 |
/// Copy constructor.
|
kpeter@579
|
60 |
GraphItem(const GraphItem &) {}
|
kpeter@579
|
61 |
|
kpeter@579
|
62 |
/// \brief Constructor for conversion from \c INVALID.
|
deba@57
|
63 |
///
|
kpeter@579
|
64 |
/// Constructor for conversion from \c INVALID.
|
kpeter@579
|
65 |
/// It initializes the item to be invalid.
|
deba@57
|
66 |
/// \sa Invalid for more details.
|
deba@57
|
67 |
GraphItem(Invalid) {}
|
kpeter@579
|
68 |
|
kpeter@579
|
69 |
/// \brief Assignment operator.
|
deba@57
|
70 |
///
|
kpeter@579
|
71 |
/// Assignment operator for the item.
|
kpeter@579
|
72 |
GraphItem& operator=(const GraphItem&) { return *this; }
|
kpeter@579
|
73 |
|
alpar@666
|
74 |
/// \brief Assignment operator for INVALID.
|
alpar@666
|
75 |
///
|
alpar@666
|
76 |
/// This operator makes the item invalid.
|
alpar@666
|
77 |
GraphItem& operator=(Invalid) { return *this; }
|
alpar@666
|
78 |
|
deba@57
|
79 |
/// \brief Equality operator.
|
deba@57
|
80 |
///
|
kpeter@579
|
81 |
/// Equality operator.
|
kpeter@579
|
82 |
bool operator==(const GraphItem&) const { return false; }
|
kpeter@579
|
83 |
|
deba@57
|
84 |
/// \brief Inequality operator.
|
deba@57
|
85 |
///
|
kpeter@579
|
86 |
/// Inequality operator.
|
kpeter@579
|
87 |
bool operator!=(const GraphItem&) const { return false; }
|
kpeter@579
|
88 |
|
kpeter@579
|
89 |
/// \brief Ordering operator.
|
deba@57
|
90 |
///
|
kpeter@579
|
91 |
/// This operator defines an ordering of the items.
|
alpar@877
|
92 |
/// It makes possible to use graph item types as key types in
|
kpeter@579
|
93 |
/// associative containers (e.g. \c std::map).
|
deba@57
|
94 |
///
|
kpeter@734
|
95 |
/// \note This operator only has to define some strict ordering of
|
deba@57
|
96 |
/// the items; this order has nothing to do with the iteration
|
deba@57
|
97 |
/// ordering of the items.
|
kpeter@579
|
98 |
bool operator<(const GraphItem&) const { return false; }
|
deba@57
|
99 |
|
deba@57
|
100 |
template<typename _GraphItem>
|
deba@57
|
101 |
struct Constraints {
|
alpar@209
|
102 |
void constraints() {
|
alpar@209
|
103 |
_GraphItem i1;
|
alpar@666
|
104 |
i1=INVALID;
|
alpar@209
|
105 |
_GraphItem i2 = i1;
|
alpar@209
|
106 |
_GraphItem i3 = INVALID;
|
deba@57
|
107 |
|
alpar@209
|
108 |
i1 = i2 = i3;
|
alpar@209
|
109 |
|
alpar@209
|
110 |
bool b;
|
alpar@1007
|
111 |
ignore_unused_variable_warning(b);
|
alpar@1007
|
112 |
|
alpar@209
|
113 |
b = (ia == ib) && (ia != ib);
|
alpar@209
|
114 |
b = (ia == INVALID) && (ib != INVALID);
|
deba@57
|
115 |
b = (ia < ib);
|
alpar@209
|
116 |
}
|
deba@57
|
117 |
|
alpar@209
|
118 |
const _GraphItem &ia;
|
alpar@209
|
119 |
const _GraphItem &ib;
|
alpar@975
|
120 |
Constraints() {}
|
deba@57
|
121 |
};
|
deba@57
|
122 |
};
|
deba@57
|
123 |
|
kpeter@579
|
124 |
/// \brief Base skeleton class for directed graphs.
|
alpar@209
|
125 |
///
|
kpeter@579
|
126 |
/// This class describes the base interface of directed graph types.
|
kpeter@579
|
127 |
/// All digraph %concepts have to conform to this class.
|
alpar@877
|
128 |
/// It just provides types for nodes and arcs and functions
|
kpeter@579
|
129 |
/// to get the source and the target nodes of arcs.
|
deba@57
|
130 |
class BaseDigraphComponent {
|
deba@57
|
131 |
public:
|
deba@57
|
132 |
|
deba@57
|
133 |
typedef BaseDigraphComponent Digraph;
|
alpar@209
|
134 |
|
deba@57
|
135 |
/// \brief Node class of the digraph.
|
deba@57
|
136 |
///
|
kpeter@579
|
137 |
/// This class represents the nodes of the digraph.
|
deba@57
|
138 |
typedef GraphItem<'n'> Node;
|
deba@57
|
139 |
|
deba@57
|
140 |
/// \brief Arc class of the digraph.
|
deba@57
|
141 |
///
|
kpeter@579
|
142 |
/// This class represents the arcs of the digraph.
|
kpeter@579
|
143 |
typedef GraphItem<'a'> Arc;
|
kpeter@579
|
144 |
|
kpeter@579
|
145 |
/// \brief Return the source node of an arc.
|
deba@57
|
146 |
///
|
kpeter@579
|
147 |
/// This function returns the source node of an arc.
|
kpeter@579
|
148 |
Node source(const Arc&) const { return INVALID; }
|
deba@57
|
149 |
|
kpeter@579
|
150 |
/// \brief Return the target node of an arc.
|
deba@57
|
151 |
///
|
kpeter@579
|
152 |
/// This function returns the target node of an arc.
|
kpeter@579
|
153 |
Node target(const Arc&) const { return INVALID; }
|
kpeter@579
|
154 |
|
kpeter@579
|
155 |
/// \brief Return the opposite node on the given arc.
|
deba@57
|
156 |
///
|
kpeter@579
|
157 |
/// This function returns the opposite node on the given arc.
|
deba@57
|
158 |
Node oppositeNode(const Node&, const Arc&) const {
|
deba@57
|
159 |
return INVALID;
|
deba@57
|
160 |
}
|
deba@57
|
161 |
|
deba@57
|
162 |
template <typename _Digraph>
|
deba@57
|
163 |
struct Constraints {
|
alpar@209
|
164 |
typedef typename _Digraph::Node Node;
|
alpar@209
|
165 |
typedef typename _Digraph::Arc Arc;
|
alpar@209
|
166 |
|
alpar@209
|
167 |
void constraints() {
|
alpar@209
|
168 |
checkConcept<GraphItem<'n'>, Node>();
|
alpar@209
|
169 |
checkConcept<GraphItem<'a'>, Arc>();
|
alpar@209
|
170 |
{
|
alpar@209
|
171 |
Node n;
|
alpar@209
|
172 |
Arc e(INVALID);
|
alpar@209
|
173 |
n = digraph.source(e);
|
alpar@209
|
174 |
n = digraph.target(e);
|
deba@57
|
175 |
n = digraph.oppositeNode(n, e);
|
alpar@209
|
176 |
}
|
alpar@209
|
177 |
}
|
alpar@209
|
178 |
|
alpar@209
|
179 |
const _Digraph& digraph;
|
alpar@975
|
180 |
Constraints() {}
|
deba@57
|
181 |
};
|
deba@57
|
182 |
};
|
deba@57
|
183 |
|
kpeter@579
|
184 |
/// \brief Base skeleton class for undirected graphs.
|
alpar@209
|
185 |
///
|
kpeter@579
|
186 |
/// This class describes the base interface of undirected graph types.
|
kpeter@579
|
187 |
/// All graph %concepts have to conform to this class.
|
kpeter@579
|
188 |
/// It extends the interface of \ref BaseDigraphComponent with an
|
kpeter@579
|
189 |
/// \c Edge type and functions to get the end nodes of edges,
|
kpeter@579
|
190 |
/// to convert from arcs to edges and to get both direction of edges.
|
deba@57
|
191 |
class BaseGraphComponent : public BaseDigraphComponent {
|
deba@57
|
192 |
public:
|
kpeter@617
|
193 |
|
kpeter@617
|
194 |
typedef BaseGraphComponent Graph;
|
kpeter@617
|
195 |
|
deba@57
|
196 |
typedef BaseDigraphComponent::Node Node;
|
deba@57
|
197 |
typedef BaseDigraphComponent::Arc Arc;
|
kpeter@579
|
198 |
|
kpeter@579
|
199 |
/// \brief Undirected edge class of the graph.
|
deba@57
|
200 |
///
|
kpeter@579
|
201 |
/// This class represents the undirected edges of the graph.
|
kpeter@579
|
202 |
/// Undirected graphs can be used as directed graphs, each edge is
|
kpeter@579
|
203 |
/// represented by two opposite directed arcs.
|
kpeter@579
|
204 |
class Edge : public GraphItem<'e'> {
|
kpeter@579
|
205 |
typedef GraphItem<'e'> Parent;
|
kpeter@579
|
206 |
|
kpeter@617
|
207 |
public:
|
deba@57
|
208 |
/// \brief Default constructor.
|
alpar@209
|
209 |
///
|
kpeter@579
|
210 |
/// Default constructor.
|
deba@57
|
211 |
/// \warning The default constructor is not required to set
|
deba@57
|
212 |
/// the item to some well-defined value. So you should consider it
|
deba@57
|
213 |
/// as uninitialized.
|
deba@57
|
214 |
Edge() {}
|
kpeter@579
|
215 |
|
deba@57
|
216 |
/// \brief Copy constructor.
|
deba@57
|
217 |
///
|
deba@57
|
218 |
/// Copy constructor.
|
kpeter@579
|
219 |
Edge(const Edge &) : Parent() {}
|
kpeter@579
|
220 |
|
kpeter@579
|
221 |
/// \brief Constructor for conversion from \c INVALID.
|
deba@57
|
222 |
///
|
kpeter@579
|
223 |
/// Constructor for conversion from \c INVALID.
|
kpeter@579
|
224 |
/// It initializes the item to be invalid.
|
deba@57
|
225 |
/// \sa Invalid for more details.
|
deba@57
|
226 |
Edge(Invalid) {}
|
kpeter@579
|
227 |
|
kpeter@579
|
228 |
/// \brief Constructor for conversion from an arc.
|
deba@57
|
229 |
///
|
kpeter@579
|
230 |
/// Constructor for conversion from an arc.
|
deba@57
|
231 |
/// Besides the core graph item functionality each arc should
|
alpar@209
|
232 |
/// be convertible to the represented edge.
|
deba@57
|
233 |
Edge(const Arc&) {}
|
alpar@666
|
234 |
};
|
deba@57
|
235 |
|
kpeter@579
|
236 |
/// \brief Return one end node of an edge.
|
kpeter@579
|
237 |
///
|
kpeter@579
|
238 |
/// This function returns one end node of an edge.
|
kpeter@579
|
239 |
Node u(const Edge&) const { return INVALID; }
|
kpeter@579
|
240 |
|
kpeter@579
|
241 |
/// \brief Return the other end node of an edge.
|
kpeter@579
|
242 |
///
|
kpeter@579
|
243 |
/// This function returns the other end node of an edge.
|
kpeter@579
|
244 |
Node v(const Edge&) const { return INVALID; }
|
kpeter@579
|
245 |
|
kpeter@579
|
246 |
/// \brief Return a directed arc related to an edge.
|
kpeter@579
|
247 |
///
|
kpeter@579
|
248 |
/// This function returns a directed arc from its direction and the
|
kpeter@579
|
249 |
/// represented edge.
|
kpeter@579
|
250 |
Arc direct(const Edge&, bool) const { return INVALID; }
|
kpeter@579
|
251 |
|
kpeter@579
|
252 |
/// \brief Return a directed arc related to an edge.
|
kpeter@579
|
253 |
///
|
kpeter@579
|
254 |
/// This function returns a directed arc from its source node and the
|
kpeter@579
|
255 |
/// represented edge.
|
kpeter@579
|
256 |
Arc direct(const Edge&, const Node&) const { return INVALID; }
|
kpeter@579
|
257 |
|
kpeter@579
|
258 |
/// \brief Return the direction of the arc.
|
deba@57
|
259 |
///
|
deba@57
|
260 |
/// Returns the direction of the arc. Each arc represents an
|
deba@57
|
261 |
/// edge with a direction. It gives back the
|
deba@57
|
262 |
/// direction.
|
deba@57
|
263 |
bool direction(const Arc&) const { return true; }
|
deba@57
|
264 |
|
kpeter@579
|
265 |
/// \brief Return the opposite arc.
|
deba@57
|
266 |
///
|
kpeter@579
|
267 |
/// This function returns the opposite arc, i.e. the arc representing
|
kpeter@579
|
268 |
/// the same edge and has opposite direction.
|
kpeter@579
|
269 |
Arc oppositeArc(const Arc&) const { return INVALID; }
|
alpar@209
|
270 |
|
deba@57
|
271 |
template <typename _Graph>
|
deba@57
|
272 |
struct Constraints {
|
alpar@209
|
273 |
typedef typename _Graph::Node Node;
|
alpar@209
|
274 |
typedef typename _Graph::Arc Arc;
|
alpar@209
|
275 |
typedef typename _Graph::Edge Edge;
|
alpar@209
|
276 |
|
alpar@209
|
277 |
void constraints() {
|
deba@57
|
278 |
checkConcept<BaseDigraphComponent, _Graph>();
|
kpeter@579
|
279 |
checkConcept<GraphItem<'e'>, Edge>();
|
alpar@209
|
280 |
{
|
alpar@209
|
281 |
Node n;
|
alpar@209
|
282 |
Edge ue(INVALID);
|
deba@57
|
283 |
Arc e;
|
alpar@209
|
284 |
n = graph.u(ue);
|
alpar@209
|
285 |
n = graph.v(ue);
|
deba@57
|
286 |
e = graph.direct(ue, true);
|
kpeter@579
|
287 |
e = graph.direct(ue, false);
|
deba@57
|
288 |
e = graph.direct(ue, n);
|
deba@57
|
289 |
e = graph.oppositeArc(e);
|
deba@57
|
290 |
ue = e;
|
deba@57
|
291 |
bool d = graph.direction(e);
|
deba@57
|
292 |
ignore_unused_variable_warning(d);
|
alpar@209
|
293 |
}
|
alpar@209
|
294 |
}
|
alpar@209
|
295 |
|
alpar@209
|
296 |
const _Graph& graph;
|
alpar@975
|
297 |
Constraints() {}
|
deba@57
|
298 |
};
|
deba@57
|
299 |
|
deba@57
|
300 |
};
|
deba@57
|
301 |
|
deba@1018
|
302 |
/// \brief Base skeleton class for undirected bipartite graphs.
|
deba@1018
|
303 |
///
|
deba@1018
|
304 |
/// This class describes the base interface of undirected
|
deba@1018
|
305 |
/// bipartite graph types. All bipartite graph %concepts have to
|
deba@1018
|
306 |
/// conform to this class. It extends the interface of \ref
|
deba@1018
|
307 |
/// BaseGraphComponent with an \c Edge type and functions to get
|
deba@1018
|
308 |
/// the end nodes of edges, to convert from arcs to edges and to
|
deba@1018
|
309 |
/// get both direction of edges.
|
deba@1018
|
310 |
class BaseBpGraphComponent : public BaseGraphComponent {
|
deba@1018
|
311 |
public:
|
deba@1018
|
312 |
|
deba@1018
|
313 |
typedef BaseBpGraphComponent BpGraph;
|
deba@1018
|
314 |
|
deba@1018
|
315 |
typedef BaseDigraphComponent::Node Node;
|
deba@1018
|
316 |
typedef BaseDigraphComponent::Arc Arc;
|
deba@1018
|
317 |
|
deba@1018
|
318 |
/// \brief Class to represent red nodes.
|
deba@1018
|
319 |
///
|
deba@1018
|
320 |
/// This class represents the red nodes of the graph. It does
|
deba@1018
|
321 |
/// not supposed to be used directly, because the nodes can be
|
deba@1018
|
322 |
/// represented as Node instances. This class can be used as
|
deba@1018
|
323 |
/// template parameter for special map classes.
|
deba@1018
|
324 |
class RedNode : public Node {
|
deba@1018
|
325 |
typedef Node Parent;
|
deba@1018
|
326 |
|
deba@1018
|
327 |
public:
|
deba@1018
|
328 |
/// \brief Default constructor.
|
deba@1018
|
329 |
///
|
deba@1018
|
330 |
/// Default constructor.
|
deba@1018
|
331 |
/// \warning The default constructor is not required to set
|
deba@1018
|
332 |
/// the item to some well-defined value. So you should consider it
|
deba@1018
|
333 |
/// as uninitialized.
|
deba@1018
|
334 |
RedNode() {}
|
deba@1018
|
335 |
|
deba@1018
|
336 |
/// \brief Copy constructor.
|
deba@1018
|
337 |
///
|
deba@1018
|
338 |
/// Copy constructor.
|
deba@1018
|
339 |
RedNode(const RedNode &) : Parent() {}
|
deba@1018
|
340 |
|
deba@1018
|
341 |
/// \brief Constructor for conversion from \c INVALID.
|
deba@1018
|
342 |
///
|
deba@1018
|
343 |
/// Constructor for conversion from \c INVALID.
|
deba@1018
|
344 |
/// It initializes the item to be invalid.
|
deba@1018
|
345 |
/// \sa Invalid for more details.
|
deba@1018
|
346 |
RedNode(Invalid) {}
|
deba@1018
|
347 |
|
deba@1018
|
348 |
/// \brief Constructor for conversion from a node.
|
deba@1018
|
349 |
///
|
deba@1018
|
350 |
/// Constructor for conversion from a node. The conversion can
|
deba@1018
|
351 |
/// be invalid, since the Node can be member of the blue
|
deba@1018
|
352 |
/// set.
|
deba@1018
|
353 |
RedNode(const Node&) {}
|
deba@1018
|
354 |
};
|
deba@1018
|
355 |
|
deba@1018
|
356 |
/// \brief Class to represent blue nodes.
|
deba@1018
|
357 |
///
|
deba@1018
|
358 |
/// This class represents the blue nodes of the graph. It does
|
deba@1018
|
359 |
/// not supposed to be used directly, because the nodes can be
|
deba@1018
|
360 |
/// represented as Node instances. This class can be used as
|
deba@1018
|
361 |
/// template parameter for special map classes.
|
deba@1018
|
362 |
class BlueNode : public Node {
|
deba@1018
|
363 |
typedef Node Parent;
|
deba@1018
|
364 |
|
deba@1018
|
365 |
public:
|
deba@1018
|
366 |
/// \brief Default constructor.
|
deba@1018
|
367 |
///
|
deba@1018
|
368 |
/// Default constructor.
|
deba@1018
|
369 |
/// \warning The default constructor is not required to set
|
deba@1018
|
370 |
/// the item to some well-defined value. So you should consider it
|
deba@1018
|
371 |
/// as uninitialized.
|
deba@1018
|
372 |
BlueNode() {}
|
deba@1018
|
373 |
|
deba@1018
|
374 |
/// \brief Copy constructor.
|
deba@1018
|
375 |
///
|
deba@1018
|
376 |
/// Copy constructor.
|
deba@1018
|
377 |
BlueNode(const BlueNode &) : Parent() {}
|
deba@1018
|
378 |
|
deba@1018
|
379 |
/// \brief Constructor for conversion from \c INVALID.
|
deba@1018
|
380 |
///
|
deba@1018
|
381 |
/// Constructor for conversion from \c INVALID.
|
deba@1018
|
382 |
/// It initializes the item to be invalid.
|
deba@1018
|
383 |
/// \sa Invalid for more details.
|
deba@1018
|
384 |
BlueNode(Invalid) {}
|
deba@1018
|
385 |
|
deba@1018
|
386 |
/// \brief Constructor for conversion from a node.
|
deba@1018
|
387 |
///
|
deba@1018
|
388 |
/// Constructor for conversion from a node. The conversion can
|
deba@1018
|
389 |
/// be invalid, since the Node can be member of the red
|
deba@1018
|
390 |
/// set.
|
deba@1018
|
391 |
BlueNode(const Node&) {}
|
deba@1018
|
392 |
};
|
deba@1018
|
393 |
|
deba@1018
|
394 |
/// \brief Gives back %true for red nodes.
|
deba@1018
|
395 |
///
|
deba@1018
|
396 |
/// Gives back %true for red nodes.
|
deba@1018
|
397 |
bool red(const Node&) const { return true; }
|
deba@1018
|
398 |
|
deba@1018
|
399 |
/// \brief Gives back %true for blue nodes.
|
deba@1018
|
400 |
///
|
deba@1018
|
401 |
/// Gives back %true for blue nodes.
|
deba@1018
|
402 |
bool blue(const Node&) const { return true; }
|
deba@1018
|
403 |
|
deba@1018
|
404 |
/// \brief Gives back the red end node of the edge.
|
deba@1018
|
405 |
///
|
deba@1018
|
406 |
/// Gives back the red end node of the edge.
|
deba@1018
|
407 |
Node redNode(const Edge&) const { return Node(); }
|
deba@1018
|
408 |
|
deba@1018
|
409 |
/// \brief Gives back the blue end node of the edge.
|
deba@1018
|
410 |
///
|
deba@1018
|
411 |
/// Gives back the blue end node of the edge.
|
deba@1018
|
412 |
Node blueNode(const Edge&) const { return Node(); }
|
deba@1018
|
413 |
|
deba@1018
|
414 |
template <typename _BpGraph>
|
deba@1018
|
415 |
struct Constraints {
|
deba@1018
|
416 |
typedef typename _BpGraph::Node Node;
|
deba@1018
|
417 |
typedef typename _BpGraph::RedNode RedNode;
|
deba@1018
|
418 |
typedef typename _BpGraph::BlueNode BlueNode;
|
deba@1018
|
419 |
typedef typename _BpGraph::Arc Arc;
|
deba@1018
|
420 |
typedef typename _BpGraph::Edge Edge;
|
deba@1018
|
421 |
|
deba@1018
|
422 |
void constraints() {
|
deba@1018
|
423 |
checkConcept<BaseGraphComponent, _BpGraph>();
|
deba@1018
|
424 |
checkConcept<GraphItem<'n'>, RedNode>();
|
deba@1018
|
425 |
checkConcept<GraphItem<'n'>, BlueNode>();
|
deba@1018
|
426 |
{
|
deba@1018
|
427 |
Node n;
|
deba@1018
|
428 |
RedNode rn = n;
|
deba@1018
|
429 |
BlueNode bn = bn;
|
deba@1018
|
430 |
Edge e;
|
deba@1018
|
431 |
bool b;
|
deba@1018
|
432 |
b = bpgraph.red(n);
|
deba@1018
|
433 |
b = bpgraph.blue(n);
|
deba@1018
|
434 |
ignore_unused_variable_warning(b);
|
deba@1018
|
435 |
n = bpgraph.redNode(e);
|
deba@1018
|
436 |
n = bpgraph.blueNode(e);
|
deba@1018
|
437 |
rn = n;
|
deba@1018
|
438 |
bn = n;
|
deba@1018
|
439 |
}
|
deba@1018
|
440 |
}
|
deba@1018
|
441 |
|
deba@1018
|
442 |
const _BpGraph& bpgraph;
|
deba@1018
|
443 |
};
|
deba@1018
|
444 |
|
deba@1018
|
445 |
};
|
deba@1018
|
446 |
|
kpeter@579
|
447 |
/// \brief Skeleton class for \e idable directed graphs.
|
alpar@209
|
448 |
///
|
kpeter@579
|
449 |
/// This class describes the interface of \e idable directed graphs.
|
kpeter@579
|
450 |
/// It extends \ref BaseDigraphComponent with the core ID functions.
|
kpeter@579
|
451 |
/// The ids of the items must be unique and immutable.
|
kpeter@579
|
452 |
/// This concept is part of the Digraph concept.
|
kpeter@559
|
453 |
template <typename BAS = BaseDigraphComponent>
|
kpeter@559
|
454 |
class IDableDigraphComponent : public BAS {
|
deba@57
|
455 |
public:
|
deba@57
|
456 |
|
kpeter@559
|
457 |
typedef BAS Base;
|
deba@57
|
458 |
typedef typename Base::Node Node;
|
deba@57
|
459 |
typedef typename Base::Arc Arc;
|
deba@57
|
460 |
|
kpeter@579
|
461 |
/// \brief Return a unique integer id for the given node.
|
deba@57
|
462 |
///
|
kpeter@579
|
463 |
/// This function returns a unique integer id for the given node.
|
kpeter@579
|
464 |
int id(const Node&) const { return -1; }
|
kpeter@579
|
465 |
|
kpeter@579
|
466 |
/// \brief Return the node by its unique id.
|
deba@57
|
467 |
///
|
kpeter@579
|
468 |
/// This function returns the node by its unique id.
|
kpeter@579
|
469 |
/// If the digraph does not contain a node with the given id,
|
kpeter@579
|
470 |
/// then the result of the function is undefined.
|
kpeter@579
|
471 |
Node nodeFromId(int) const { return INVALID; }
|
deba@57
|
472 |
|
kpeter@579
|
473 |
/// \brief Return a unique integer id for the given arc.
|
deba@57
|
474 |
///
|
kpeter@579
|
475 |
/// This function returns a unique integer id for the given arc.
|
kpeter@579
|
476 |
int id(const Arc&) const { return -1; }
|
deba@57
|
477 |
|
kpeter@579
|
478 |
/// \brief Return the arc by its unique id.
|
deba@57
|
479 |
///
|
kpeter@579
|
480 |
/// This function returns the arc by its unique id.
|
kpeter@579
|
481 |
/// If the digraph does not contain an arc with the given id,
|
kpeter@579
|
482 |
/// then the result of the function is undefined.
|
kpeter@579
|
483 |
Arc arcFromId(int) const { return INVALID; }
|
kpeter@579
|
484 |
|
kpeter@579
|
485 |
/// \brief Return an integer greater or equal to the maximum
|
kpeter@579
|
486 |
/// node id.
|
deba@57
|
487 |
///
|
kpeter@579
|
488 |
/// This function returns an integer greater or equal to the
|
kpeter@579
|
489 |
/// maximum node id.
|
kpeter@579
|
490 |
int maxNodeId() const { return -1; }
|
deba@57
|
491 |
|
kpeter@579
|
492 |
/// \brief Return an integer greater or equal to the maximum
|
kpeter@579
|
493 |
/// arc id.
|
deba@57
|
494 |
///
|
kpeter@579
|
495 |
/// This function returns an integer greater or equal to the
|
kpeter@579
|
496 |
/// maximum arc id.
|
kpeter@579
|
497 |
int maxArcId() const { return -1; }
|
deba@57
|
498 |
|
deba@57
|
499 |
template <typename _Digraph>
|
deba@57
|
500 |
struct Constraints {
|
deba@57
|
501 |
|
alpar@209
|
502 |
void constraints() {
|
alpar@209
|
503 |
checkConcept<Base, _Digraph >();
|
alpar@209
|
504 |
typename _Digraph::Node node;
|
alpar@666
|
505 |
node=INVALID;
|
alpar@209
|
506 |
int nid = digraph.id(node);
|
alpar@209
|
507 |
nid = digraph.id(node);
|
alpar@209
|
508 |
node = digraph.nodeFromId(nid);
|
alpar@209
|
509 |
typename _Digraph::Arc arc;
|
alpar@666
|
510 |
arc=INVALID;
|
alpar@209
|
511 |
int eid = digraph.id(arc);
|
alpar@209
|
512 |
eid = digraph.id(arc);
|
alpar@209
|
513 |
arc = digraph.arcFromId(eid);
|
deba@57
|
514 |
|
alpar@209
|
515 |
nid = digraph.maxNodeId();
|
alpar@209
|
516 |
ignore_unused_variable_warning(nid);
|
alpar@209
|
517 |
eid = digraph.maxArcId();
|
alpar@209
|
518 |
ignore_unused_variable_warning(eid);
|
alpar@209
|
519 |
}
|
deba@57
|
520 |
|
alpar@209
|
521 |
const _Digraph& digraph;
|
alpar@975
|
522 |
Constraints() {}
|
deba@57
|
523 |
};
|
deba@57
|
524 |
};
|
deba@57
|
525 |
|
kpeter@579
|
526 |
/// \brief Skeleton class for \e idable undirected graphs.
|
alpar@209
|
527 |
///
|
kpeter@579
|
528 |
/// This class describes the interface of \e idable undirected
|
kpeter@579
|
529 |
/// graphs. It extends \ref IDableDigraphComponent with the core ID
|
kpeter@579
|
530 |
/// functions of undirected graphs.
|
kpeter@579
|
531 |
/// The ids of the items must be unique and immutable.
|
kpeter@579
|
532 |
/// This concept is part of the Graph concept.
|
kpeter@559
|
533 |
template <typename BAS = BaseGraphComponent>
|
kpeter@559
|
534 |
class IDableGraphComponent : public IDableDigraphComponent<BAS> {
|
deba@57
|
535 |
public:
|
deba@57
|
536 |
|
kpeter@559
|
537 |
typedef BAS Base;
|
deba@57
|
538 |
typedef typename Base::Edge Edge;
|
deba@57
|
539 |
|
kpeter@559
|
540 |
using IDableDigraphComponent<Base>::id;
|
deba@57
|
541 |
|
kpeter@579
|
542 |
/// \brief Return a unique integer id for the given edge.
|
deba@57
|
543 |
///
|
kpeter@579
|
544 |
/// This function returns a unique integer id for the given edge.
|
kpeter@579
|
545 |
int id(const Edge&) const { return -1; }
|
kpeter@579
|
546 |
|
kpeter@579
|
547 |
/// \brief Return the edge by its unique id.
|
deba@57
|
548 |
///
|
kpeter@579
|
549 |
/// This function returns the edge by its unique id.
|
kpeter@579
|
550 |
/// If the graph does not contain an edge with the given id,
|
kpeter@579
|
551 |
/// then the result of the function is undefined.
|
kpeter@579
|
552 |
Edge edgeFromId(int) const { return INVALID; }
|
deba@57
|
553 |
|
kpeter@579
|
554 |
/// \brief Return an integer greater or equal to the maximum
|
kpeter@579
|
555 |
/// edge id.
|
deba@57
|
556 |
///
|
kpeter@579
|
557 |
/// This function returns an integer greater or equal to the
|
kpeter@579
|
558 |
/// maximum edge id.
|
kpeter@579
|
559 |
int maxEdgeId() const { return -1; }
|
deba@57
|
560 |
|
deba@57
|
561 |
template <typename _Graph>
|
deba@57
|
562 |
struct Constraints {
|
deba@57
|
563 |
|
alpar@209
|
564 |
void constraints() {
|
alpar@209
|
565 |
checkConcept<IDableDigraphComponent<Base>, _Graph >();
|
alpar@209
|
566 |
typename _Graph::Edge edge;
|
alpar@209
|
567 |
int ueid = graph.id(edge);
|
alpar@209
|
568 |
ueid = graph.id(edge);
|
alpar@209
|
569 |
edge = graph.edgeFromId(ueid);
|
alpar@209
|
570 |
ueid = graph.maxEdgeId();
|
alpar@209
|
571 |
ignore_unused_variable_warning(ueid);
|
alpar@209
|
572 |
}
|
deba@57
|
573 |
|
alpar@209
|
574 |
const _Graph& graph;
|
alpar@975
|
575 |
Constraints() {}
|
deba@57
|
576 |
};
|
deba@57
|
577 |
};
|
deba@57
|
578 |
|
deba@1018
|
579 |
/// \brief Skeleton class for \e idable undirected bipartite graphs.
|
deba@1018
|
580 |
///
|
deba@1018
|
581 |
/// This class describes the interface of \e idable undirected
|
deba@1018
|
582 |
/// bipartite graphs. It extends \ref IDableGraphComponent with
|
deba@1018
|
583 |
/// the core ID functions of undirected bipartite graphs. Beside
|
deba@1018
|
584 |
/// the regular node ids, this class also provides ids within the
|
deba@1018
|
585 |
/// the red and blue sets of the nodes. This concept is part of
|
deba@1018
|
586 |
/// the BpGraph concept.
|
deba@1018
|
587 |
template <typename BAS = BaseBpGraphComponent>
|
deba@1018
|
588 |
class IDableBpGraphComponent : public IDableGraphComponent<BAS> {
|
deba@1018
|
589 |
public:
|
deba@1018
|
590 |
|
deba@1018
|
591 |
typedef BAS Base;
|
deba@1018
|
592 |
typedef IDableGraphComponent<BAS> Parent;
|
deba@1018
|
593 |
typedef typename Base::Node Node;
|
deba@1018
|
594 |
typedef typename Base::RedNode RedNode;
|
deba@1018
|
595 |
typedef typename Base::BlueNode BlueNode;
|
deba@1018
|
596 |
|
deba@1018
|
597 |
using Parent::id;
|
deba@1018
|
598 |
|
deba@1018
|
599 |
/// \brief Return a unique integer id for the given node in the red set.
|
deba@1018
|
600 |
///
|
deba@1018
|
601 |
/// Return a unique integer id for the given node in the red set.
|
deba@1018
|
602 |
int redId(const Node&) const { return -1; }
|
deba@1018
|
603 |
|
deba@1018
|
604 |
/// \brief Return the same value as redId().
|
deba@1018
|
605 |
///
|
deba@1018
|
606 |
/// Return the same value as redId().
|
deba@1018
|
607 |
int id(const RedNode&) const { return -1; }
|
deba@1018
|
608 |
|
deba@1018
|
609 |
/// \brief Return a unique integer id for the given node in the blue set.
|
deba@1018
|
610 |
///
|
deba@1018
|
611 |
/// Return a unique integer id for the given node in the blue set.
|
deba@1018
|
612 |
int blueId(const Node&) const { return -1; }
|
deba@1018
|
613 |
|
deba@1018
|
614 |
/// \brief Return the same value as blueId().
|
deba@1018
|
615 |
///
|
deba@1018
|
616 |
/// Return the same value as blueId().
|
deba@1018
|
617 |
int id(const BlueNode&) const { return -1; }
|
deba@1018
|
618 |
|
deba@1018
|
619 |
/// \brief Return an integer greater or equal to the maximum
|
deba@1018
|
620 |
/// node id in the red set.
|
deba@1018
|
621 |
///
|
deba@1018
|
622 |
/// Return an integer greater or equal to the maximum
|
deba@1018
|
623 |
/// node id in the red set.
|
deba@1018
|
624 |
int maxRedId() const { return -1; }
|
deba@1018
|
625 |
|
deba@1018
|
626 |
/// \brief Return an integer greater or equal to the maximum
|
deba@1018
|
627 |
/// node id in the blue set.
|
deba@1018
|
628 |
///
|
deba@1018
|
629 |
/// Return an integer greater or equal to the maximum
|
deba@1018
|
630 |
/// node id in the blue set.
|
deba@1018
|
631 |
int maxBlueId() const { return -1; }
|
deba@1018
|
632 |
|
deba@1018
|
633 |
template <typename _BpGraph>
|
deba@1018
|
634 |
struct Constraints {
|
deba@1018
|
635 |
|
deba@1018
|
636 |
void constraints() {
|
deba@1018
|
637 |
checkConcept<IDableGraphComponent<Base>, _BpGraph>();
|
deba@1018
|
638 |
typename _BpGraph::Node node;
|
deba@1018
|
639 |
typename _BpGraph::RedNode red;
|
deba@1018
|
640 |
typename _BpGraph::BlueNode blue;
|
deba@1018
|
641 |
int rid = bpgraph.redId(node);
|
deba@1018
|
642 |
int bid = bpgraph.blueId(node);
|
deba@1018
|
643 |
rid = bpgraph.id(red);
|
deba@1018
|
644 |
bid = bpgraph.id(blue);
|
deba@1018
|
645 |
rid = bpgraph.maxRedId();
|
deba@1018
|
646 |
bid = bpgraph.maxBlueId();
|
deba@1018
|
647 |
ignore_unused_variable_warning(rid);
|
deba@1018
|
648 |
ignore_unused_variable_warning(bid);
|
deba@1018
|
649 |
}
|
deba@1018
|
650 |
|
deba@1018
|
651 |
const _BpGraph& bpgraph;
|
deba@1018
|
652 |
};
|
deba@1018
|
653 |
};
|
deba@1018
|
654 |
|
kpeter@579
|
655 |
/// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
|
deba@57
|
656 |
///
|
alpar@877
|
657 |
/// This class describes the concept of \c NodeIt, \c ArcIt and
|
kpeter@579
|
658 |
/// \c EdgeIt subtypes of digraph and graph types.
|
kpeter@559
|
659 |
template <typename GR, typename Item>
|
kpeter@559
|
660 |
class GraphItemIt : public Item {
|
deba@57
|
661 |
public:
|
deba@57
|
662 |
/// \brief Default constructor.
|
deba@57
|
663 |
///
|
kpeter@579
|
664 |
/// Default constructor.
|
kpeter@579
|
665 |
/// \warning The default constructor is not required to set
|
kpeter@579
|
666 |
/// the iterator to some well-defined value. So you should consider it
|
kpeter@579
|
667 |
/// as uninitialized.
|
deba@57
|
668 |
GraphItemIt() {}
|
kpeter@579
|
669 |
|
deba@57
|
670 |
/// \brief Copy constructor.
|
deba@57
|
671 |
///
|
deba@57
|
672 |
/// Copy constructor.
|
kpeter@579
|
673 |
GraphItemIt(const GraphItemIt& it) : Item(it) {}
|
kpeter@579
|
674 |
|
kpeter@579
|
675 |
/// \brief Constructor that sets the iterator to the first item.
|
deba@57
|
676 |
///
|
kpeter@579
|
677 |
/// Constructor that sets the iterator to the first item.
|
kpeter@579
|
678 |
explicit GraphItemIt(const GR&) {}
|
kpeter@579
|
679 |
|
kpeter@579
|
680 |
/// \brief Constructor for conversion from \c INVALID.
|
deba@57
|
681 |
///
|
kpeter@579
|
682 |
/// Constructor for conversion from \c INVALID.
|
kpeter@579
|
683 |
/// It initializes the iterator to be invalid.
|
deba@57
|
684 |
/// \sa Invalid for more details.
|
deba@57
|
685 |
GraphItemIt(Invalid) {}
|
kpeter@579
|
686 |
|
kpeter@579
|
687 |
/// \brief Assignment operator.
|
deba@57
|
688 |
///
|
kpeter@579
|
689 |
/// Assignment operator for the iterator.
|
kpeter@579
|
690 |
GraphItemIt& operator=(const GraphItemIt&) { return *this; }
|
kpeter@579
|
691 |
|
kpeter@579
|
692 |
/// \brief Increment the iterator.
|
deba@57
|
693 |
///
|
kpeter@579
|
694 |
/// This operator increments the iterator, i.e. assigns it to the
|
kpeter@579
|
695 |
/// next item.
|
deba@57
|
696 |
GraphItemIt& operator++() { return *this; }
|
alpar@877
|
697 |
|
deba@57
|
698 |
/// \brief Equality operator
|
alpar@209
|
699 |
///
|
kpeter@579
|
700 |
/// Equality operator.
|
deba@57
|
701 |
/// Two iterators are equal if and only if they point to the
|
deba@57
|
702 |
/// same object or both are invalid.
|
deba@57
|
703 |
bool operator==(const GraphItemIt&) const { return true;}
|
kpeter@579
|
704 |
|
deba@57
|
705 |
/// \brief Inequality operator
|
alpar@209
|
706 |
///
|
kpeter@579
|
707 |
/// Inequality operator.
|
kpeter@579
|
708 |
/// Two iterators are equal if and only if they point to the
|
kpeter@579
|
709 |
/// same object or both are invalid.
|
deba@57
|
710 |
bool operator!=(const GraphItemIt&) const { return true;}
|
alpar@209
|
711 |
|
deba@57
|
712 |
template<typename _GraphItemIt>
|
deba@57
|
713 |
struct Constraints {
|
alpar@209
|
714 |
void constraints() {
|
kpeter@579
|
715 |
checkConcept<GraphItem<>, _GraphItemIt>();
|
alpar@209
|
716 |
_GraphItemIt it1(g);
|
alpar@209
|
717 |
_GraphItemIt it2;
|
kpeter@579
|
718 |
_GraphItemIt it3 = it1;
|
kpeter@579
|
719 |
_GraphItemIt it4 = INVALID;
|
alpar@997
|
720 |
ignore_unused_variable_warning(it3);
|
alpar@997
|
721 |
ignore_unused_variable_warning(it4);
|
deba@57
|
722 |
|
alpar@209
|
723 |
it2 = ++it1;
|
alpar@209
|
724 |
++it2 = it1;
|
alpar@209
|
725 |
++(++it1);
|
deba@57
|
726 |
|
kpeter@559
|
727 |
Item bi = it1;
|
alpar@209
|
728 |
bi = it2;
|
alpar@209
|
729 |
}
|
kpeter@579
|
730 |
const GR& g;
|
alpar@975
|
731 |
Constraints() {}
|
deba@57
|
732 |
};
|
deba@57
|
733 |
};
|
deba@57
|
734 |
|
alpar@877
|
735 |
/// \brief Concept class for \c InArcIt, \c OutArcIt and
|
kpeter@579
|
736 |
/// \c IncEdgeIt types.
|
deba@57
|
737 |
///
|
alpar@877
|
738 |
/// This class describes the concept of \c InArcIt, \c OutArcIt
|
kpeter@579
|
739 |
/// and \c IncEdgeIt subtypes of digraph and graph types.
|
kpeter@579
|
740 |
///
|
kpeter@579
|
741 |
/// \note Since these iterator classes do not inherit from the same
|
kpeter@579
|
742 |
/// base class, there is an additional template parameter (selector)
|
alpar@877
|
743 |
/// \c sel. For \c InArcIt you should instantiate it with character
|
kpeter@579
|
744 |
/// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
|
kpeter@559
|
745 |
template <typename GR,
|
kpeter@559
|
746 |
typename Item = typename GR::Arc,
|
kpeter@559
|
747 |
typename Base = typename GR::Node,
|
kpeter@559
|
748 |
char sel = '0'>
|
kpeter@559
|
749 |
class GraphIncIt : public Item {
|
deba@57
|
750 |
public:
|
deba@57
|
751 |
/// \brief Default constructor.
|
deba@57
|
752 |
///
|
kpeter@579
|
753 |
/// Default constructor.
|
kpeter@579
|
754 |
/// \warning The default constructor is not required to set
|
kpeter@579
|
755 |
/// the iterator to some well-defined value. So you should consider it
|
kpeter@579
|
756 |
/// as uninitialized.
|
deba@57
|
757 |
GraphIncIt() {}
|
kpeter@579
|
758 |
|
deba@57
|
759 |
/// \brief Copy constructor.
|
deba@57
|
760 |
///
|
deba@57
|
761 |
/// Copy constructor.
|
kpeter@579
|
762 |
GraphIncIt(const GraphIncIt& it) : Item(it) {}
|
kpeter@579
|
763 |
|
alpar@877
|
764 |
/// \brief Constructor that sets the iterator to the first
|
kpeter@579
|
765 |
/// incoming or outgoing arc.
|
deba@57
|
766 |
///
|
alpar@877
|
767 |
/// Constructor that sets the iterator to the first arc
|
kpeter@579
|
768 |
/// incoming to or outgoing from the given node.
|
kpeter@579
|
769 |
explicit GraphIncIt(const GR&, const Base&) {}
|
kpeter@579
|
770 |
|
kpeter@579
|
771 |
/// \brief Constructor for conversion from \c INVALID.
|
deba@57
|
772 |
///
|
kpeter@579
|
773 |
/// Constructor for conversion from \c INVALID.
|
kpeter@579
|
774 |
/// It initializes the iterator to be invalid.
|
deba@57
|
775 |
/// \sa Invalid for more details.
|
deba@57
|
776 |
GraphIncIt(Invalid) {}
|
kpeter@579
|
777 |
|
kpeter@579
|
778 |
/// \brief Assignment operator.
|
deba@57
|
779 |
///
|
kpeter@579
|
780 |
/// Assignment operator for the iterator.
|
kpeter@579
|
781 |
GraphIncIt& operator=(const GraphIncIt&) { return *this; }
|
kpeter@579
|
782 |
|
kpeter@579
|
783 |
/// \brief Increment the iterator.
|
deba@57
|
784 |
///
|
kpeter@579
|
785 |
/// This operator increments the iterator, i.e. assigns it to the
|
kpeter@579
|
786 |
/// next arc incoming to or outgoing from the given node.
|
deba@57
|
787 |
GraphIncIt& operator++() { return *this; }
|
deba@57
|
788 |
|
deba@57
|
789 |
/// \brief Equality operator
|
deba@57
|
790 |
///
|
kpeter@579
|
791 |
/// Equality operator.
|
deba@57
|
792 |
/// Two iterators are equal if and only if they point to the
|
deba@57
|
793 |
/// same object or both are invalid.
|
deba@57
|
794 |
bool operator==(const GraphIncIt&) const { return true;}
|
deba@57
|
795 |
|
deba@57
|
796 |
/// \brief Inequality operator
|
deba@57
|
797 |
///
|
kpeter@579
|
798 |
/// Inequality operator.
|
kpeter@579
|
799 |
/// Two iterators are equal if and only if they point to the
|
kpeter@579
|
800 |
/// same object or both are invalid.
|
deba@57
|
801 |
bool operator!=(const GraphIncIt&) const { return true;}
|
deba@57
|
802 |
|
deba@57
|
803 |
template <typename _GraphIncIt>
|
deba@57
|
804 |
struct Constraints {
|
alpar@209
|
805 |
void constraints() {
|
kpeter@559
|
806 |
checkConcept<GraphItem<sel>, _GraphIncIt>();
|
alpar@209
|
807 |
_GraphIncIt it1(graph, node);
|
alpar@209
|
808 |
_GraphIncIt it2;
|
kpeter@579
|
809 |
_GraphIncIt it3 = it1;
|
kpeter@579
|
810 |
_GraphIncIt it4 = INVALID;
|
alpar@997
|
811 |
ignore_unused_variable_warning(it3);
|
alpar@997
|
812 |
ignore_unused_variable_warning(it4);
|
deba@57
|
813 |
|
alpar@209
|
814 |
it2 = ++it1;
|
alpar@209
|
815 |
++it2 = it1;
|
alpar@209
|
816 |
++(++it1);
|
kpeter@559
|
817 |
Item e = it1;
|
alpar@209
|
818 |
e = it2;
|
alpar@209
|
819 |
}
|
kpeter@579
|
820 |
const Base& node;
|
kpeter@579
|
821 |
const GR& graph;
|
alpar@975
|
822 |
Constraints() {}
|
deba@57
|
823 |
};
|
deba@57
|
824 |
};
|
deba@57
|
825 |
|
kpeter@579
|
826 |
/// \brief Skeleton class for iterable directed graphs.
|
deba@57
|
827 |
///
|
kpeter@579
|
828 |
/// This class describes the interface of iterable directed
|
kpeter@579
|
829 |
/// graphs. It extends \ref BaseDigraphComponent with the core
|
kpeter@579
|
830 |
/// iterable interface.
|
deba@57
|
831 |
/// This concept is part of the Digraph concept.
|
kpeter@559
|
832 |
template <typename BAS = BaseDigraphComponent>
|
kpeter@559
|
833 |
class IterableDigraphComponent : public BAS {
|
deba@57
|
834 |
|
deba@57
|
835 |
public:
|
alpar@209
|
836 |
|
kpeter@559
|
837 |
typedef BAS Base;
|
deba@57
|
838 |
typedef typename Base::Node Node;
|
deba@57
|
839 |
typedef typename Base::Arc Arc;
|
deba@57
|
840 |
|
deba@57
|
841 |
typedef IterableDigraphComponent Digraph;
|
deba@57
|
842 |
|
kpeter@584
|
843 |
/// \name Base Iteration
|
alpar@209
|
844 |
///
|
kpeter@579
|
845 |
/// This interface provides functions for iteration on digraph items.
|
deba@57
|
846 |
///
|
alpar@209
|
847 |
/// @{
|
deba@57
|
848 |
|
kpeter@579
|
849 |
/// \brief Return the first node.
|
alpar@209
|
850 |
///
|
kpeter@579
|
851 |
/// This function gives back the first node in the iteration order.
|
deba@57
|
852 |
void first(Node&) const {}
|
deba@57
|
853 |
|
kpeter@579
|
854 |
/// \brief Return the next node.
|
deba@57
|
855 |
///
|
kpeter@579
|
856 |
/// This function gives back the next node in the iteration order.
|
deba@57
|
857 |
void next(Node&) const {}
|
deba@57
|
858 |
|
kpeter@579
|
859 |
/// \brief Return the first arc.
|
deba@57
|
860 |
///
|
kpeter@579
|
861 |
/// This function gives back the first arc in the iteration order.
|
deba@57
|
862 |
void first(Arc&) const {}
|
deba@57
|
863 |
|
kpeter@579
|
864 |
/// \brief Return the next arc.
|
deba@57
|
865 |
///
|
kpeter@579
|
866 |
/// This function gives back the next arc in the iteration order.
|
deba@57
|
867 |
void next(Arc&) const {}
|
deba@57
|
868 |
|
kpeter@579
|
869 |
/// \brief Return the first arc incomming to the given node.
|
deba@57
|
870 |
///
|
kpeter@579
|
871 |
/// This function gives back the first arc incomming to the
|
kpeter@579
|
872 |
/// given node.
|
deba@57
|
873 |
void firstIn(Arc&, const Node&) const {}
|
deba@57
|
874 |
|
kpeter@579
|
875 |
/// \brief Return the next arc incomming to the given node.
|
deba@57
|
876 |
///
|
kpeter@579
|
877 |
/// This function gives back the next arc incomming to the
|
kpeter@579
|
878 |
/// given node.
|
deba@57
|
879 |
void nextIn(Arc&) const {}
|
deba@57
|
880 |
|
kpeter@579
|
881 |
/// \brief Return the first arc outgoing form the given node.
|
kpeter@579
|
882 |
///
|
kpeter@579
|
883 |
/// This function gives back the first arc outgoing form the
|
deba@57
|
884 |
/// given node.
|
deba@57
|
885 |
void firstOut(Arc&, const Node&) const {}
|
deba@57
|
886 |
|
kpeter@579
|
887 |
/// \brief Return the next arc outgoing form the given node.
|
deba@57
|
888 |
///
|
kpeter@579
|
889 |
/// This function gives back the next arc outgoing form the
|
kpeter@579
|
890 |
/// given node.
|
deba@57
|
891 |
void nextOut(Arc&) const {}
|
deba@57
|
892 |
|
deba@57
|
893 |
/// @}
|
deba@57
|
894 |
|
kpeter@584
|
895 |
/// \name Class Based Iteration
|
alpar@209
|
896 |
///
|
kpeter@579
|
897 |
/// This interface provides iterator classes for digraph items.
|
deba@57
|
898 |
///
|
deba@57
|
899 |
/// @{
|
deba@57
|
900 |
|
deba@57
|
901 |
/// \brief This iterator goes through each node.
|
deba@57
|
902 |
///
|
deba@57
|
903 |
/// This iterator goes through each node.
|
deba@57
|
904 |
///
|
deba@57
|
905 |
typedef GraphItemIt<Digraph, Node> NodeIt;
|
deba@57
|
906 |
|
kpeter@579
|
907 |
/// \brief This iterator goes through each arc.
|
deba@57
|
908 |
///
|
kpeter@579
|
909 |
/// This iterator goes through each arc.
|
deba@57
|
910 |
///
|
deba@57
|
911 |
typedef GraphItemIt<Digraph, Arc> ArcIt;
|
deba@57
|
912 |
|
deba@57
|
913 |
/// \brief This iterator goes trough the incoming arcs of a node.
|
deba@57
|
914 |
///
|
kpeter@579
|
915 |
/// This iterator goes trough the \e incoming arcs of a certain node
|
deba@57
|
916 |
/// of a digraph.
|
deba@57
|
917 |
typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
|
deba@57
|
918 |
|
deba@57
|
919 |
/// \brief This iterator goes trough the outgoing arcs of a node.
|
deba@57
|
920 |
///
|
deba@57
|
921 |
/// This iterator goes trough the \e outgoing arcs of a certain node
|
deba@57
|
922 |
/// of a digraph.
|
deba@57
|
923 |
typedef GraphIncIt<Digraph, Arc, Node, 'o'> OutArcIt;
|
deba@57
|
924 |
|
deba@57
|
925 |
/// \brief The base node of the iterator.
|
deba@57
|
926 |
///
|
kpeter@579
|
927 |
/// This function gives back the base node of the iterator.
|
kpeter@579
|
928 |
/// It is always the target node of the pointed arc.
|
deba@57
|
929 |
Node baseNode(const InArcIt&) const { return INVALID; }
|
deba@57
|
930 |
|
deba@57
|
931 |
/// \brief The running node of the iterator.
|
deba@57
|
932 |
///
|
kpeter@579
|
933 |
/// This function gives back the running node of the iterator.
|
kpeter@579
|
934 |
/// It is always the source node of the pointed arc.
|
deba@57
|
935 |
Node runningNode(const InArcIt&) const { return INVALID; }
|
deba@57
|
936 |
|
deba@57
|
937 |
/// \brief The base node of the iterator.
|
deba@57
|
938 |
///
|
kpeter@579
|
939 |
/// This function gives back the base node of the iterator.
|
kpeter@579
|
940 |
/// It is always the source node of the pointed arc.
|
deba@57
|
941 |
Node baseNode(const OutArcIt&) const { return INVALID; }
|
deba@57
|
942 |
|
deba@57
|
943 |
/// \brief The running node of the iterator.
|
deba@57
|
944 |
///
|
kpeter@579
|
945 |
/// This function gives back the running node of the iterator.
|
kpeter@579
|
946 |
/// It is always the target node of the pointed arc.
|
deba@57
|
947 |
Node runningNode(const OutArcIt&) const { return INVALID; }
|
deba@57
|
948 |
|
deba@57
|
949 |
/// @}
|
deba@57
|
950 |
|
alpar@209
|
951 |
template <typename _Digraph>
|
deba@57
|
952 |
struct Constraints {
|
alpar@209
|
953 |
void constraints() {
|
alpar@209
|
954 |
checkConcept<Base, _Digraph>();
|
deba@57
|
955 |
|
deba@57
|
956 |
{
|
alpar@209
|
957 |
typename _Digraph::Node node(INVALID);
|
deba@57
|
958 |
typename _Digraph::Arc arc(INVALID);
|
deba@57
|
959 |
{
|
deba@57
|
960 |
digraph.first(node);
|
deba@57
|
961 |
digraph.next(node);
|
deba@57
|
962 |
}
|
deba@57
|
963 |
{
|
deba@57
|
964 |
digraph.first(arc);
|
deba@57
|
965 |
digraph.next(arc);
|
deba@57
|
966 |
}
|
deba@57
|
967 |
{
|
deba@57
|
968 |
digraph.firstIn(arc, node);
|
deba@57
|
969 |
digraph.nextIn(arc);
|
deba@57
|
970 |
}
|
deba@57
|
971 |
{
|
deba@57
|
972 |
digraph.firstOut(arc, node);
|
deba@57
|
973 |
digraph.nextOut(arc);
|
deba@57
|
974 |
}
|
alpar@209
|
975 |
}
|
deba@57
|
976 |
|
deba@57
|
977 |
{
|
deba@57
|
978 |
checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
|
deba@57
|
979 |
typename _Digraph::ArcIt >();
|
deba@57
|
980 |
checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
|
deba@57
|
981 |
typename _Digraph::NodeIt >();
|
alpar@209
|
982 |
checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
|
deba@57
|
983 |
typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
|
alpar@209
|
984 |
checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
|
deba@57
|
985 |
typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
|
deba@57
|
986 |
|
deba@57
|
987 |
typename _Digraph::Node n;
|
kpeter@579
|
988 |
const typename _Digraph::InArcIt iait(INVALID);
|
kpeter@579
|
989 |
const typename _Digraph::OutArcIt oait(INVALID);
|
kpeter@579
|
990 |
n = digraph.baseNode(iait);
|
kpeter@579
|
991 |
n = digraph.runningNode(iait);
|
kpeter@579
|
992 |
n = digraph.baseNode(oait);
|
kpeter@579
|
993 |
n = digraph.runningNode(oait);
|
deba@57
|
994 |
ignore_unused_variable_warning(n);
|
deba@57
|
995 |
}
|
deba@57
|
996 |
}
|
alpar@209
|
997 |
|
alpar@209
|
998 |
const _Digraph& digraph;
|
alpar@975
|
999 |
Constraints() {}
|
deba@57
|
1000 |
};
|
deba@57
|
1001 |
};
|
deba@57
|
1002 |
|
kpeter@579
|
1003 |
/// \brief Skeleton class for iterable undirected graphs.
|
deba@57
|
1004 |
///
|
kpeter@579
|
1005 |
/// This class describes the interface of iterable undirected
|
kpeter@579
|
1006 |
/// graphs. It extends \ref IterableDigraphComponent with the core
|
kpeter@579
|
1007 |
/// iterable interface of undirected graphs.
|
deba@57
|
1008 |
/// This concept is part of the Graph concept.
|
kpeter@559
|
1009 |
template <typename BAS = BaseGraphComponent>
|
kpeter@559
|
1010 |
class IterableGraphComponent : public IterableDigraphComponent<BAS> {
|
deba@57
|
1011 |
public:
|
deba@57
|
1012 |
|
kpeter@559
|
1013 |
typedef BAS Base;
|
deba@57
|
1014 |
typedef typename Base::Node Node;
|
deba@57
|
1015 |
typedef typename Base::Arc Arc;
|
deba@57
|
1016 |
typedef typename Base::Edge Edge;
|
deba@57
|
1017 |
|
alpar@209
|
1018 |
|
deba@57
|
1019 |
typedef IterableGraphComponent Graph;
|
deba@57
|
1020 |
|
kpeter@584
|
1021 |
/// \name Base Iteration
|
alpar@209
|
1022 |
///
|
kpeter@579
|
1023 |
/// This interface provides functions for iteration on edges.
|
kpeter@579
|
1024 |
///
|
alpar@209
|
1025 |
/// @{
|
deba@57
|
1026 |
|
kpeter@559
|
1027 |
using IterableDigraphComponent<Base>::first;
|
kpeter@559
|
1028 |
using IterableDigraphComponent<Base>::next;
|
deba@57
|
1029 |
|
kpeter@579
|
1030 |
/// \brief Return the first edge.
|
deba@57
|
1031 |
///
|
kpeter@579
|
1032 |
/// This function gives back the first edge in the iteration order.
|
deba@57
|
1033 |
void first(Edge&) const {}
|
deba@57
|
1034 |
|
kpeter@579
|
1035 |
/// \brief Return the next edge.
|
deba@57
|
1036 |
///
|
kpeter@579
|
1037 |
/// This function gives back the next edge in the iteration order.
|
deba@57
|
1038 |
void next(Edge&) const {}
|
deba@57
|
1039 |
|
kpeter@579
|
1040 |
/// \brief Return the first edge incident to the given node.
|
kpeter@579
|
1041 |
///
|
alpar@877
|
1042 |
/// This function gives back the first edge incident to the given
|
kpeter@579
|
1043 |
/// node. The bool parameter gives back the direction for which the
|
alpar@877
|
1044 |
/// source node of the directed arc representing the edge is the
|
deba@57
|
1045 |
/// given node.
|
deba@57
|
1046 |
void firstInc(Edge&, bool&, const Node&) const {}
|
deba@57
|
1047 |
|
deba@57
|
1048 |
/// \brief Gives back the next of the edges from the
|
deba@57
|
1049 |
/// given node.
|
deba@57
|
1050 |
///
|
alpar@877
|
1051 |
/// This function gives back the next edge incident to the given
|
kpeter@579
|
1052 |
/// node. The bool parameter should be used as \c firstInc() use it.
|
deba@57
|
1053 |
void nextInc(Edge&, bool&) const {}
|
deba@57
|
1054 |
|
kpeter@559
|
1055 |
using IterableDigraphComponent<Base>::baseNode;
|
kpeter@559
|
1056 |
using IterableDigraphComponent<Base>::runningNode;
|
deba@57
|
1057 |
|
deba@57
|
1058 |
/// @}
|
deba@57
|
1059 |
|
kpeter@584
|
1060 |
/// \name Class Based Iteration
|
alpar@209
|
1061 |
///
|
kpeter@579
|
1062 |
/// This interface provides iterator classes for edges.
|
deba@57
|
1063 |
///
|
deba@57
|
1064 |
/// @{
|
deba@57
|
1065 |
|
kpeter@579
|
1066 |
/// \brief This iterator goes through each edge.
|
deba@57
|
1067 |
///
|
kpeter@579
|
1068 |
/// This iterator goes through each edge.
|
deba@57
|
1069 |
typedef GraphItemIt<Graph, Edge> EdgeIt;
|
kpeter@579
|
1070 |
|
kpeter@579
|
1071 |
/// \brief This iterator goes trough the incident edges of a
|
deba@57
|
1072 |
/// node.
|
deba@57
|
1073 |
///
|
kpeter@579
|
1074 |
/// This iterator goes trough the incident edges of a certain
|
deba@57
|
1075 |
/// node of a graph.
|
kpeter@579
|
1076 |
typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
|
kpeter@579
|
1077 |
|
deba@57
|
1078 |
/// \brief The base node of the iterator.
|
deba@57
|
1079 |
///
|
kpeter@579
|
1080 |
/// This function gives back the base node of the iterator.
|
deba@78
|
1081 |
Node baseNode(const IncEdgeIt&) const { return INVALID; }
|
deba@57
|
1082 |
|
deba@57
|
1083 |
/// \brief The running node of the iterator.
|
deba@57
|
1084 |
///
|
kpeter@579
|
1085 |
/// This function gives back the running node of the iterator.
|
deba@78
|
1086 |
Node runningNode(const IncEdgeIt&) const { return INVALID; }
|
deba@57
|
1087 |
|
deba@57
|
1088 |
/// @}
|
deba@57
|
1089 |
|
alpar@209
|
1090 |
template <typename _Graph>
|
deba@57
|
1091 |
struct Constraints {
|
alpar@209
|
1092 |
void constraints() {
|
alpar@209
|
1093 |
checkConcept<IterableDigraphComponent<Base>, _Graph>();
|
deba@57
|
1094 |
|
deba@57
|
1095 |
{
|
deba@57
|
1096 |
typename _Graph::Node node(INVALID);
|
deba@57
|
1097 |
typename _Graph::Edge edge(INVALID);
|
deba@57
|
1098 |
bool dir;
|
deba@57
|
1099 |
{
|
deba@57
|
1100 |
graph.first(edge);
|
deba@57
|
1101 |
graph.next(edge);
|
deba@57
|
1102 |
}
|
deba@57
|
1103 |
{
|
deba@57
|
1104 |
graph.firstInc(edge, dir, node);
|
deba@57
|
1105 |
graph.nextInc(edge, dir);
|
deba@57
|
1106 |
}
|
alpar@209
|
1107 |
|
alpar@209
|
1108 |
}
|
alpar@209
|
1109 |
|
deba@57
|
1110 |
{
|
deba@57
|
1111 |
checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
|
deba@57
|
1112 |
typename _Graph::EdgeIt >();
|
alpar@209
|
1113 |
checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
|
kpeter@579
|
1114 |
typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
|
alpar@209
|
1115 |
|
deba@57
|
1116 |
typename _Graph::Node n;
|
kpeter@579
|
1117 |
const typename _Graph::IncEdgeIt ieit(INVALID);
|
kpeter@579
|
1118 |
n = graph.baseNode(ieit);
|
kpeter@579
|
1119 |
n = graph.runningNode(ieit);
|
deba@57
|
1120 |
}
|
deba@57
|
1121 |
}
|
alpar@209
|
1122 |
|
alpar@209
|
1123 |
const _Graph& graph;
|
alpar@975
|
1124 |
Constraints() {}
|
deba@57
|
1125 |
};
|
deba@57
|
1126 |
};
|
deba@57
|
1127 |
|
deba@1018
|
1128 |
/// \brief Skeleton class for iterable undirected bipartite graphs.
|
deba@1018
|
1129 |
///
|
deba@1018
|
1130 |
/// This class describes the interface of iterable undirected
|
deba@1018
|
1131 |
/// bipartite graphs. It extends \ref IterableGraphComponent with
|
deba@1018
|
1132 |
/// the core iterable interface of undirected bipartite graphs.
|
deba@1018
|
1133 |
/// This concept is part of the BpGraph concept.
|
deba@1018
|
1134 |
template <typename BAS = BaseBpGraphComponent>
|
deba@1018
|
1135 |
class IterableBpGraphComponent : public IterableGraphComponent<BAS> {
|
deba@1018
|
1136 |
public:
|
deba@1018
|
1137 |
|
deba@1018
|
1138 |
typedef BAS Base;
|
deba@1018
|
1139 |
typedef typename Base::Node Node;
|
deba@1018
|
1140 |
typedef typename Base::Arc Arc;
|
deba@1018
|
1141 |
typedef typename Base::Edge Edge;
|
deba@1018
|
1142 |
|
deba@1018
|
1143 |
|
deba@1018
|
1144 |
typedef IterableBpGraphComponent BpGraph;
|
deba@1018
|
1145 |
|
deba@1018
|
1146 |
/// \name Base Iteration
|
deba@1018
|
1147 |
///
|
deba@1018
|
1148 |
/// This interface provides functions for iteration on red and blue nodes.
|
deba@1018
|
1149 |
///
|
deba@1018
|
1150 |
/// @{
|
deba@1018
|
1151 |
|
deba@1018
|
1152 |
/// \brief Return the first red node.
|
deba@1018
|
1153 |
///
|
deba@1018
|
1154 |
/// This function gives back the first red node in the iteration order.
|
deba@1018
|
1155 |
void firstRed(Node&) const {}
|
deba@1018
|
1156 |
|
deba@1018
|
1157 |
/// \brief Return the next red node.
|
deba@1018
|
1158 |
///
|
deba@1018
|
1159 |
/// This function gives back the next red node in the iteration order.
|
deba@1018
|
1160 |
void nextRed(Node&) const {}
|
deba@1018
|
1161 |
|
deba@1018
|
1162 |
/// \brief Return the first blue node.
|
deba@1018
|
1163 |
///
|
deba@1018
|
1164 |
/// This function gives back the first blue node in the iteration order.
|
deba@1018
|
1165 |
void firstBlue(Node&) const {}
|
deba@1018
|
1166 |
|
deba@1018
|
1167 |
/// \brief Return the next blue node.
|
deba@1018
|
1168 |
///
|
deba@1018
|
1169 |
/// This function gives back the next blue node in the iteration order.
|
deba@1018
|
1170 |
void nextBlue(Node&) const {}
|
deba@1018
|
1171 |
|
deba@1018
|
1172 |
|
deba@1018
|
1173 |
/// @}
|
deba@1018
|
1174 |
|
deba@1018
|
1175 |
/// \name Class Based Iteration
|
deba@1018
|
1176 |
///
|
deba@1018
|
1177 |
/// This interface provides iterator classes for red and blue nodes.
|
deba@1018
|
1178 |
///
|
deba@1018
|
1179 |
/// @{
|
deba@1018
|
1180 |
|
deba@1018
|
1181 |
/// \brief This iterator goes through each red node.
|
deba@1018
|
1182 |
///
|
deba@1018
|
1183 |
/// This iterator goes through each red node.
|
deba@1018
|
1184 |
typedef GraphItemIt<BpGraph, Node> RedIt;
|
deba@1018
|
1185 |
|
deba@1018
|
1186 |
/// \brief This iterator goes through each blue node.
|
deba@1018
|
1187 |
///
|
deba@1018
|
1188 |
/// This iterator goes through each blue node.
|
deba@1018
|
1189 |
typedef GraphItemIt<BpGraph, Node> BlueIt;
|
deba@1018
|
1190 |
|
deba@1018
|
1191 |
/// @}
|
deba@1018
|
1192 |
|
deba@1018
|
1193 |
template <typename _BpGraph>
|
deba@1018
|
1194 |
struct Constraints {
|
deba@1018
|
1195 |
void constraints() {
|
deba@1018
|
1196 |
checkConcept<IterableGraphComponent<Base>, _BpGraph>();
|
deba@1018
|
1197 |
|
deba@1018
|
1198 |
typename _BpGraph::Node node(INVALID);
|
deba@1018
|
1199 |
bpgraph.firstRed(node);
|
deba@1018
|
1200 |
bpgraph.nextRed(node);
|
deba@1018
|
1201 |
bpgraph.firstBlue(node);
|
deba@1018
|
1202 |
bpgraph.nextBlue(node);
|
deba@1018
|
1203 |
|
deba@1018
|
1204 |
checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::Node>,
|
deba@1018
|
1205 |
typename _BpGraph::RedIt>();
|
deba@1018
|
1206 |
checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::Node>,
|
deba@1018
|
1207 |
typename _BpGraph::BlueIt>();
|
deba@1018
|
1208 |
}
|
deba@1018
|
1209 |
|
deba@1018
|
1210 |
const _BpGraph& bpgraph;
|
deba@1018
|
1211 |
};
|
deba@1018
|
1212 |
};
|
deba@1018
|
1213 |
|
kpeter@579
|
1214 |
/// \brief Skeleton class for alterable directed graphs.
|
alpar@209
|
1215 |
///
|
kpeter@579
|
1216 |
/// This class describes the interface of alterable directed
|
kpeter@579
|
1217 |
/// graphs. It extends \ref BaseDigraphComponent with the alteration
|
kpeter@579
|
1218 |
/// notifier interface. It implements
|
deba@57
|
1219 |
/// an observer-notifier pattern for each digraph item. More
|
deba@57
|
1220 |
/// obsevers can be registered into the notifier and whenever an
|
kpeter@579
|
1221 |
/// alteration occured in the digraph all the observers will be
|
deba@57
|
1222 |
/// notified about it.
|
kpeter@559
|
1223 |
template <typename BAS = BaseDigraphComponent>
|
kpeter@559
|
1224 |
class AlterableDigraphComponent : public BAS {
|
deba@57
|
1225 |
public:
|
deba@57
|
1226 |
|
kpeter@559
|
1227 |
typedef BAS Base;
|
deba@57
|
1228 |
typedef typename Base::Node Node;
|
deba@57
|
1229 |
typedef typename Base::Arc Arc;
|
deba@57
|
1230 |
|
deba@57
|
1231 |
|
kpeter@579
|
1232 |
/// Node alteration notifier class.
|
alpar@209
|
1233 |
typedef AlterationNotifier<AlterableDigraphComponent, Node>
|
deba@57
|
1234 |
NodeNotifier;
|
kpeter@579
|
1235 |
/// Arc alteration notifier class.
|
alpar@209
|
1236 |
typedef AlterationNotifier<AlterableDigraphComponent, Arc>
|
deba@57
|
1237 |
ArcNotifier;
|
alpar@209
|
1238 |
|
deba@1018
|
1239 |
mutable NodeNotifier node_notifier;
|
deba@1018
|
1240 |
mutable ArcNotifier arc_notifier;
|
deba@1018
|
1241 |
|
kpeter@579
|
1242 |
/// \brief Return the node alteration notifier.
|
deba@57
|
1243 |
///
|
kpeter@579
|
1244 |
/// This function gives back the node alteration notifier.
|
deba@57
|
1245 |
NodeNotifier& notifier(Node) const {
|
deba@1018
|
1246 |
return node_notifier;
|
deba@57
|
1247 |
}
|
alpar@209
|
1248 |
|
kpeter@579
|
1249 |
/// \brief Return the arc alteration notifier.
|
deba@57
|
1250 |
///
|
kpeter@579
|
1251 |
/// This function gives back the arc alteration notifier.
|
deba@57
|
1252 |
ArcNotifier& notifier(Arc) const {
|
deba@1018
|
1253 |
return arc_notifier;
|
deba@57
|
1254 |
}
|
deba@57
|
1255 |
|
alpar@209
|
1256 |
template <typename _Digraph>
|
deba@57
|
1257 |
struct Constraints {
|
alpar@209
|
1258 |
void constraints() {
|
alpar@209
|
1259 |
checkConcept<Base, _Digraph>();
|
alpar@209
|
1260 |
typename _Digraph::NodeNotifier& nn
|
deba@57
|
1261 |
= digraph.notifier(typename _Digraph::Node());
|
deba@57
|
1262 |
|
alpar@209
|
1263 |
typename _Digraph::ArcNotifier& en
|
deba@57
|
1264 |
= digraph.notifier(typename _Digraph::Arc());
|
alpar@209
|
1265 |
|
deba@57
|
1266 |
ignore_unused_variable_warning(nn);
|
deba@57
|
1267 |
ignore_unused_variable_warning(en);
|
alpar@209
|
1268 |
}
|
alpar@209
|
1269 |
|
alpar@209
|
1270 |
const _Digraph& digraph;
|
alpar@975
|
1271 |
Constraints() {}
|
deba@57
|
1272 |
};
|
deba@57
|
1273 |
};
|
deba@57
|
1274 |
|
kpeter@579
|
1275 |
/// \brief Skeleton class for alterable undirected graphs.
|
alpar@209
|
1276 |
///
|
kpeter@579
|
1277 |
/// This class describes the interface of alterable undirected
|
kpeter@579
|
1278 |
/// graphs. It extends \ref AlterableDigraphComponent with the alteration
|
kpeter@579
|
1279 |
/// notifier interface of undirected graphs. It implements
|
kpeter@579
|
1280 |
/// an observer-notifier pattern for the edges. More
|
deba@57
|
1281 |
/// obsevers can be registered into the notifier and whenever an
|
kpeter@579
|
1282 |
/// alteration occured in the graph all the observers will be
|
deba@57
|
1283 |
/// notified about it.
|
kpeter@559
|
1284 |
template <typename BAS = BaseGraphComponent>
|
kpeter@559
|
1285 |
class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
|
deba@57
|
1286 |
public:
|
deba@57
|
1287 |
|
kpeter@559
|
1288 |
typedef BAS Base;
|
deba@1018
|
1289 |
typedef AlterableDigraphComponent<Base> Parent;
|
deba@57
|
1290 |
typedef typename Base::Edge Edge;
|
deba@57
|
1291 |
|
deba@57
|
1292 |
|
kpeter@579
|
1293 |
/// Edge alteration notifier class.
|
alpar@209
|
1294 |
typedef AlterationNotifier<AlterableGraphComponent, Edge>
|
deba@57
|
1295 |
EdgeNotifier;
|
alpar@209
|
1296 |
|
deba@1018
|
1297 |
mutable EdgeNotifier edge_notifier;
|
deba@1018
|
1298 |
|
deba@1018
|
1299 |
using Parent::notifier;
|
deba@1018
|
1300 |
|
kpeter@579
|
1301 |
/// \brief Return the edge alteration notifier.
|
deba@57
|
1302 |
///
|
kpeter@579
|
1303 |
/// This function gives back the edge alteration notifier.
|
deba@57
|
1304 |
EdgeNotifier& notifier(Edge) const {
|
deba@1018
|
1305 |
return edge_notifier;
|
deba@57
|
1306 |
}
|
deba@57
|
1307 |
|
alpar@209
|
1308 |
template <typename _Graph>
|
deba@57
|
1309 |
struct Constraints {
|
alpar@209
|
1310 |
void constraints() {
|
kpeter@579
|
1311 |
checkConcept<AlterableDigraphComponent<Base>, _Graph>();
|
alpar@209
|
1312 |
typename _Graph::EdgeNotifier& uen
|
deba@57
|
1313 |
= graph.notifier(typename _Graph::Edge());
|
deba@57
|
1314 |
ignore_unused_variable_warning(uen);
|
alpar@209
|
1315 |
}
|
alpar@209
|
1316 |
|
alpar@209
|
1317 |
const _Graph& graph;
|
alpar@975
|
1318 |
Constraints() {}
|
deba@57
|
1319 |
};
|
deba@57
|
1320 |
};
|
deba@57
|
1321 |
|
deba@1018
|
1322 |
/// \brief Skeleton class for alterable undirected bipartite graphs.
|
deba@1018
|
1323 |
///
|
deba@1018
|
1324 |
/// This class describes the interface of alterable undirected
|
deba@1018
|
1325 |
/// bipartite graphs. It extends \ref AlterableGraphComponent with
|
deba@1018
|
1326 |
/// the alteration notifier interface of bipartite graphs. It
|
deba@1018
|
1327 |
/// implements an observer-notifier pattern for the red and blue
|
deba@1018
|
1328 |
/// nodes. More obsevers can be registered into the notifier and
|
deba@1018
|
1329 |
/// whenever an alteration occured in the graph all the observers
|
deba@1018
|
1330 |
/// will be notified about it.
|
deba@1018
|
1331 |
template <typename BAS = BaseBpGraphComponent>
|
deba@1018
|
1332 |
class AlterableBpGraphComponent : public AlterableGraphComponent<BAS> {
|
deba@1018
|
1333 |
public:
|
deba@1018
|
1334 |
|
deba@1018
|
1335 |
typedef BAS Base;
|
deba@1018
|
1336 |
typedef AlterableGraphComponent<Base> Parent;
|
deba@1018
|
1337 |
typedef typename Base::RedNode RedNode;
|
deba@1018
|
1338 |
typedef typename Base::BlueNode BlueNode;
|
deba@1018
|
1339 |
|
deba@1018
|
1340 |
|
deba@1018
|
1341 |
/// Red node alteration notifier class.
|
deba@1018
|
1342 |
typedef AlterationNotifier<AlterableBpGraphComponent, RedNode>
|
deba@1018
|
1343 |
RedNodeNotifier;
|
deba@1018
|
1344 |
|
deba@1018
|
1345 |
/// Blue node alteration notifier class.
|
deba@1018
|
1346 |
typedef AlterationNotifier<AlterableBpGraphComponent, BlueNode>
|
deba@1018
|
1347 |
BlueNodeNotifier;
|
deba@1018
|
1348 |
|
deba@1018
|
1349 |
mutable RedNodeNotifier red_node_notifier;
|
deba@1018
|
1350 |
mutable BlueNodeNotifier blue_node_notifier;
|
deba@1018
|
1351 |
|
deba@1018
|
1352 |
using Parent::notifier;
|
deba@1018
|
1353 |
|
deba@1018
|
1354 |
/// \brief Return the red node alteration notifier.
|
deba@1018
|
1355 |
///
|
deba@1018
|
1356 |
/// This function gives back the red node alteration notifier.
|
deba@1018
|
1357 |
RedNodeNotifier& notifier(RedNode) const {
|
deba@1018
|
1358 |
return red_node_notifier;
|
deba@1018
|
1359 |
}
|
deba@1018
|
1360 |
|
deba@1018
|
1361 |
/// \brief Return the blue node alteration notifier.
|
deba@1018
|
1362 |
///
|
deba@1018
|
1363 |
/// This function gives back the blue node alteration notifier.
|
deba@1018
|
1364 |
BlueNodeNotifier& notifier(BlueNode) const {
|
deba@1018
|
1365 |
return blue_node_notifier;
|
deba@1018
|
1366 |
}
|
deba@1018
|
1367 |
|
deba@1018
|
1368 |
template <typename _BpGraph>
|
deba@1018
|
1369 |
struct Constraints {
|
deba@1018
|
1370 |
void constraints() {
|
deba@1018
|
1371 |
checkConcept<AlterableGraphComponent<Base>, _BpGraph>();
|
deba@1018
|
1372 |
typename _BpGraph::RedNodeNotifier& rnn
|
deba@1018
|
1373 |
= bpgraph.notifier(typename _BpGraph::RedNode());
|
deba@1018
|
1374 |
typename _BpGraph::BlueNodeNotifier& bnn
|
deba@1018
|
1375 |
= bpgraph.notifier(typename _BpGraph::BlueNode());
|
deba@1018
|
1376 |
ignore_unused_variable_warning(rnn);
|
deba@1018
|
1377 |
ignore_unused_variable_warning(bnn);
|
deba@1018
|
1378 |
}
|
deba@1018
|
1379 |
|
deba@1018
|
1380 |
const _BpGraph& bpgraph;
|
deba@1018
|
1381 |
};
|
deba@1018
|
1382 |
};
|
deba@1018
|
1383 |
|
kpeter@579
|
1384 |
/// \brief Concept class for standard graph maps.
|
alpar@209
|
1385 |
///
|
kpeter@579
|
1386 |
/// This class describes the concept of standard graph maps, i.e.
|
alpar@877
|
1387 |
/// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
|
kpeter@579
|
1388 |
/// graph types, which can be used for associating data to graph items.
|
kpeter@580
|
1389 |
/// The standard graph maps must conform to the ReferenceMap concept.
|
kpeter@559
|
1390 |
template <typename GR, typename K, typename V>
|
kpeter@580
|
1391 |
class GraphMap : public ReferenceMap<K, V, V&, const V&> {
|
kpeter@617
|
1392 |
typedef ReferenceMap<K, V, V&, const V&> Parent;
|
kpeter@617
|
1393 |
|
deba@57
|
1394 |
public:
|
deba@57
|
1395 |
|
deba@57
|
1396 |
/// The key type of the map.
|
kpeter@559
|
1397 |
typedef K Key;
|
deba@57
|
1398 |
/// The value type of the map.
|
kpeter@559
|
1399 |
typedef V Value;
|
kpeter@580
|
1400 |
/// The reference type of the map.
|
kpeter@580
|
1401 |
typedef Value& Reference;
|
kpeter@580
|
1402 |
/// The const reference type of the map.
|
kpeter@580
|
1403 |
typedef const Value& ConstReference;
|
kpeter@580
|
1404 |
|
kpeter@580
|
1405 |
// The reference map tag.
|
kpeter@580
|
1406 |
typedef True ReferenceMapTag;
|
deba@57
|
1407 |
|
deba@57
|
1408 |
/// \brief Construct a new map.
|
deba@57
|
1409 |
///
|
deba@57
|
1410 |
/// Construct a new map for the graph.
|
kpeter@617
|
1411 |
explicit GraphMap(const GR&) {}
|
deba@57
|
1412 |
/// \brief Construct a new map with default value.
|
deba@57
|
1413 |
///
|
kpeter@579
|
1414 |
/// Construct a new map for the graph and initalize the values.
|
kpeter@617
|
1415 |
GraphMap(const GR&, const Value&) {}
|
kpeter@263
|
1416 |
|
kpeter@263
|
1417 |
private:
|
deba@57
|
1418 |
/// \brief Copy constructor.
|
deba@57
|
1419 |
///
|
deba@57
|
1420 |
/// Copy Constructor.
|
deba@57
|
1421 |
GraphMap(const GraphMap&) : Parent() {}
|
alpar@209
|
1422 |
|
kpeter@579
|
1423 |
/// \brief Assignment operator.
|
deba@57
|
1424 |
///
|
kpeter@579
|
1425 |
/// Assignment operator. It does not mofify the underlying graph,
|
deba@57
|
1426 |
/// it just iterates on the current item set and set the map
|
alpar@209
|
1427 |
/// with the value returned by the assigned map.
|
deba@57
|
1428 |
template <typename CMap>
|
alpar@209
|
1429 |
GraphMap& operator=(const CMap&) {
|
deba@57
|
1430 |
checkConcept<ReadMap<Key, Value>, CMap>();
|
deba@57
|
1431 |
return *this;
|
deba@57
|
1432 |
}
|
deba@57
|
1433 |
|
kpeter@263
|
1434 |
public:
|
deba@57
|
1435 |
template<typename _Map>
|
deba@57
|
1436 |
struct Constraints {
|
alpar@209
|
1437 |
void constraints() {
|
kpeter@580
|
1438 |
checkConcept
|
kpeter@580
|
1439 |
<ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
|
kpeter@579
|
1440 |
_Map m1(g);
|
kpeter@579
|
1441 |
_Map m2(g,t);
|
alpar@877
|
1442 |
|
kpeter@579
|
1443 |
// Copy constructor
|
kpeter@579
|
1444 |
// _Map m3(m);
|
alpar@209
|
1445 |
|
kpeter@579
|
1446 |
// Assignment operator
|
kpeter@263
|
1447 |
// ReadMap<Key, Value> cmap;
|
kpeter@579
|
1448 |
// m3 = cmap;
|
deba@57
|
1449 |
|
kpeter@579
|
1450 |
ignore_unused_variable_warning(m1);
|
kpeter@579
|
1451 |
ignore_unused_variable_warning(m2);
|
kpeter@579
|
1452 |
// ignore_unused_variable_warning(m3);
|
alpar@209
|
1453 |
}
|
deba@57
|
1454 |
|
kpeter@579
|
1455 |
const _Map &m;
|
kpeter@617
|
1456 |
const GR &g;
|
alpar@209
|
1457 |
const typename GraphMap::Value &t;
|
alpar@975
|
1458 |
Constraints() {}
|
deba@57
|
1459 |
};
|
deba@57
|
1460 |
|
deba@57
|
1461 |
};
|
deba@57
|
1462 |
|
kpeter@579
|
1463 |
/// \brief Skeleton class for mappable directed graphs.
|
deba@57
|
1464 |
///
|
kpeter@579
|
1465 |
/// This class describes the interface of mappable directed graphs.
|
alpar@877
|
1466 |
/// It extends \ref BaseDigraphComponent with the standard digraph
|
kpeter@579
|
1467 |
/// map classes, namely \c NodeMap and \c ArcMap.
|
deba@57
|
1468 |
/// This concept is part of the Digraph concept.
|
kpeter@559
|
1469 |
template <typename BAS = BaseDigraphComponent>
|
kpeter@559
|
1470 |
class MappableDigraphComponent : public BAS {
|
deba@57
|
1471 |
public:
|
deba@57
|
1472 |
|
kpeter@559
|
1473 |
typedef BAS Base;
|
deba@57
|
1474 |
typedef typename Base::Node Node;
|
deba@57
|
1475 |
typedef typename Base::Arc Arc;
|
deba@57
|
1476 |
|
deba@57
|
1477 |
typedef MappableDigraphComponent Digraph;
|
deba@57
|
1478 |
|
kpeter@579
|
1479 |
/// \brief Standard graph map for the nodes.
|
deba@57
|
1480 |
///
|
kpeter@579
|
1481 |
/// Standard graph map for the nodes.
|
kpeter@580
|
1482 |
/// It conforms to the ReferenceMap concept.
|
kpeter@559
|
1483 |
template <typename V>
|
kpeter@579
|
1484 |
class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
|
kpeter@559
|
1485 |
typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
|
deba@57
|
1486 |
|
kpeter@617
|
1487 |
public:
|
alpar@209
|
1488 |
/// \brief Construct a new map.
|
alpar@209
|
1489 |
///
|
alpar@209
|
1490 |
/// Construct a new map for the digraph.
|
alpar@209
|
1491 |
explicit NodeMap(const MappableDigraphComponent& digraph)
|
deba@57
|
1492 |
: Parent(digraph) {}
|
deba@57
|
1493 |
|
alpar@209
|
1494 |
/// \brief Construct a new map with default value.
|
alpar@209
|
1495 |
///
|
kpeter@579
|
1496 |
/// Construct a new map for the digraph and initalize the values.
|
kpeter@559
|
1497 |
NodeMap(const MappableDigraphComponent& digraph, const V& value)
|
deba@57
|
1498 |
: Parent(digraph, value) {}
|
deba@57
|
1499 |
|
kpeter@263
|
1500 |
private:
|
alpar@209
|
1501 |
/// \brief Copy constructor.
|
alpar@209
|
1502 |
///
|
alpar@209
|
1503 |
/// Copy Constructor.
|
alpar@209
|
1504 |
NodeMap(const NodeMap& nm) : Parent(nm) {}
|
deba@57
|
1505 |
|
kpeter@579
|
1506 |
/// \brief Assignment operator.
|
alpar@209
|
1507 |
///
|
kpeter@579
|
1508 |
/// Assignment operator.
|
deba@57
|
1509 |
template <typename CMap>
|
alpar@209
|
1510 |
NodeMap& operator=(const CMap&) {
|
kpeter@559
|
1511 |
checkConcept<ReadMap<Node, V>, CMap>();
|
deba@57
|
1512 |
return *this;
|
deba@57
|
1513 |
}
|
deba@57
|
1514 |
|
deba@57
|
1515 |
};
|
deba@57
|
1516 |
|
kpeter@579
|
1517 |
/// \brief Standard graph map for the arcs.
|
deba@57
|
1518 |
///
|
kpeter@579
|
1519 |
/// Standard graph map for the arcs.
|
kpeter@580
|
1520 |
/// It conforms to the ReferenceMap concept.
|
kpeter@559
|
1521 |
template <typename V>
|
kpeter@579
|
1522 |
class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
|
kpeter@559
|
1523 |
typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
|
deba@57
|
1524 |
|
kpeter@617
|
1525 |
public:
|
alpar@209
|
1526 |
/// \brief Construct a new map.
|
alpar@209
|
1527 |
///
|
alpar@209
|
1528 |
/// Construct a new map for the digraph.
|
alpar@209
|
1529 |
explicit ArcMap(const MappableDigraphComponent& digraph)
|
deba@57
|
1530 |
: Parent(digraph) {}
|
deba@57
|
1531 |
|
alpar@209
|
1532 |
/// \brief Construct a new map with default value.
|
alpar@209
|
1533 |
///
|
kpeter@579
|
1534 |
/// Construct a new map for the digraph and initalize the values.
|
kpeter@559
|
1535 |
ArcMap(const MappableDigraphComponent& digraph, const V& value)
|
deba@57
|
1536 |
: Parent(digraph, value) {}
|
deba@57
|
1537 |
|
kpeter@263
|
1538 |
private:
|
alpar@209
|
1539 |
/// \brief Copy constructor.
|
alpar@209
|
1540 |
///
|
alpar@209
|
1541 |
/// Copy Constructor.
|
alpar@209
|
1542 |
ArcMap(const ArcMap& nm) : Parent(nm) {}
|
deba@57
|
1543 |
|
kpeter@579
|
1544 |
/// \brief Assignment operator.
|
alpar@209
|
1545 |
///
|
kpeter@579
|
1546 |
/// Assignment operator.
|
deba@57
|
1547 |
template <typename CMap>
|
alpar@209
|
1548 |
ArcMap& operator=(const CMap&) {
|
kpeter@559
|
1549 |
checkConcept<ReadMap<Arc, V>, CMap>();
|
deba@57
|
1550 |
return *this;
|
deba@57
|
1551 |
}
|
deba@57
|
1552 |
|
deba@57
|
1553 |
};
|
deba@57
|
1554 |
|
deba@57
|
1555 |
|
deba@57
|
1556 |
template <typename _Digraph>
|
deba@57
|
1557 |
struct Constraints {
|
deba@57
|
1558 |
|
alpar@209
|
1559 |
struct Dummy {
|
alpar@209
|
1560 |
int value;
|
alpar@209
|
1561 |
Dummy() : value(0) {}
|
alpar@209
|
1562 |
Dummy(int _v) : value(_v) {}
|
alpar@209
|
1563 |
};
|
deba@57
|
1564 |
|
alpar@209
|
1565 |
void constraints() {
|
alpar@209
|
1566 |
checkConcept<Base, _Digraph>();
|
alpar@209
|
1567 |
{ // int map test
|
alpar@209
|
1568 |
typedef typename _Digraph::template NodeMap<int> IntNodeMap;
|
alpar@209
|
1569 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
|
alpar@209
|
1570 |
IntNodeMap >();
|
alpar@209
|
1571 |
} { // bool map test
|
alpar@209
|
1572 |
typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
|
alpar@209
|
1573 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
|
alpar@209
|
1574 |
BoolNodeMap >();
|
alpar@209
|
1575 |
} { // Dummy map test
|
alpar@209
|
1576 |
typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
|
alpar@209
|
1577 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
|
alpar@209
|
1578 |
DummyNodeMap >();
|
alpar@209
|
1579 |
}
|
deba@57
|
1580 |
|
alpar@209
|
1581 |
{ // int map test
|
alpar@209
|
1582 |
typedef typename _Digraph::template ArcMap<int> IntArcMap;
|
alpar@209
|
1583 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
|
alpar@209
|
1584 |
IntArcMap >();
|
alpar@209
|
1585 |
} { // bool map test
|
alpar@209
|
1586 |
typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
|
alpar@209
|
1587 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
|
alpar@209
|
1588 |
BoolArcMap >();
|
alpar@209
|
1589 |
} { // Dummy map test
|
alpar@209
|
1590 |
typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
|
alpar@209
|
1591 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
|
alpar@209
|
1592 |
DummyArcMap >();
|
alpar@209
|
1593 |
}
|
alpar@209
|
1594 |
}
|
deba@57
|
1595 |
|
kpeter@579
|
1596 |
const _Digraph& digraph;
|
alpar@975
|
1597 |
Constraints() {}
|
deba@57
|
1598 |
};
|
deba@57
|
1599 |
};
|
deba@57
|
1600 |
|
kpeter@579
|
1601 |
/// \brief Skeleton class for mappable undirected graphs.
|
deba@57
|
1602 |
///
|
kpeter@579
|
1603 |
/// This class describes the interface of mappable undirected graphs.
|
alpar@877
|
1604 |
/// It extends \ref MappableDigraphComponent with the standard graph
|
kpeter@579
|
1605 |
/// map class for edges (\c EdgeMap).
|
deba@57
|
1606 |
/// This concept is part of the Graph concept.
|
kpeter@559
|
1607 |
template <typename BAS = BaseGraphComponent>
|
kpeter@559
|
1608 |
class MappableGraphComponent : public MappableDigraphComponent<BAS> {
|
deba@57
|
1609 |
public:
|
deba@57
|
1610 |
|
kpeter@559
|
1611 |
typedef BAS Base;
|
deba@57
|
1612 |
typedef typename Base::Edge Edge;
|
deba@57
|
1613 |
|
deba@57
|
1614 |
typedef MappableGraphComponent Graph;
|
deba@57
|
1615 |
|
kpeter@579
|
1616 |
/// \brief Standard graph map for the edges.
|
deba@57
|
1617 |
///
|
kpeter@579
|
1618 |
/// Standard graph map for the edges.
|
kpeter@580
|
1619 |
/// It conforms to the ReferenceMap concept.
|
kpeter@559
|
1620 |
template <typename V>
|
kpeter@579
|
1621 |
class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
|
kpeter@559
|
1622 |
typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
|
deba@57
|
1623 |
|
kpeter@617
|
1624 |
public:
|
alpar@209
|
1625 |
/// \brief Construct a new map.
|
alpar@209
|
1626 |
///
|
alpar@209
|
1627 |
/// Construct a new map for the graph.
|
alpar@209
|
1628 |
explicit EdgeMap(const MappableGraphComponent& graph)
|
deba@57
|
1629 |
: Parent(graph) {}
|
deba@57
|
1630 |
|
alpar@209
|
1631 |
/// \brief Construct a new map with default value.
|
alpar@209
|
1632 |
///
|
kpeter@579
|
1633 |
/// Construct a new map for the graph and initalize the values.
|
kpeter@559
|
1634 |
EdgeMap(const MappableGraphComponent& graph, const V& value)
|
deba@57
|
1635 |
: Parent(graph, value) {}
|
deba@57
|
1636 |
|
kpeter@263
|
1637 |
private:
|
alpar@209
|
1638 |
/// \brief Copy constructor.
|
alpar@209
|
1639 |
///
|
alpar@209
|
1640 |
/// Copy Constructor.
|
alpar@209
|
1641 |
EdgeMap(const EdgeMap& nm) : Parent(nm) {}
|
deba@57
|
1642 |
|
kpeter@579
|
1643 |
/// \brief Assignment operator.
|
alpar@209
|
1644 |
///
|
kpeter@579
|
1645 |
/// Assignment operator.
|
deba@57
|
1646 |
template <typename CMap>
|
alpar@209
|
1647 |
EdgeMap& operator=(const CMap&) {
|
kpeter@559
|
1648 |
checkConcept<ReadMap<Edge, V>, CMap>();
|
deba@57
|
1649 |
return *this;
|
deba@57
|
1650 |
}
|
deba@57
|
1651 |
|
deba@57
|
1652 |
};
|
deba@57
|
1653 |
|
deba@57
|
1654 |
|
deba@57
|
1655 |
template <typename _Graph>
|
deba@57
|
1656 |
struct Constraints {
|
deba@57
|
1657 |
|
alpar@209
|
1658 |
struct Dummy {
|
alpar@209
|
1659 |
int value;
|
alpar@209
|
1660 |
Dummy() : value(0) {}
|
alpar@209
|
1661 |
Dummy(int _v) : value(_v) {}
|
alpar@209
|
1662 |
};
|
deba@57
|
1663 |
|
alpar@209
|
1664 |
void constraints() {
|
kpeter@579
|
1665 |
checkConcept<MappableDigraphComponent<Base>, _Graph>();
|
deba@57
|
1666 |
|
alpar@209
|
1667 |
{ // int map test
|
alpar@209
|
1668 |
typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
|
alpar@209
|
1669 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
|
alpar@209
|
1670 |
IntEdgeMap >();
|
alpar@209
|
1671 |
} { // bool map test
|
alpar@209
|
1672 |
typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
|
alpar@209
|
1673 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
|
alpar@209
|
1674 |
BoolEdgeMap >();
|
alpar@209
|
1675 |
} { // Dummy map test
|
alpar@209
|
1676 |
typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
|
alpar@209
|
1677 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
|
alpar@209
|
1678 |
DummyEdgeMap >();
|
alpar@209
|
1679 |
}
|
alpar@209
|
1680 |
}
|
deba@57
|
1681 |
|
kpeter@579
|
1682 |
const _Graph& graph;
|
alpar@975
|
1683 |
Constraints() {}
|
deba@57
|
1684 |
};
|
deba@57
|
1685 |
};
|
deba@57
|
1686 |
|
deba@1018
|
1687 |
/// \brief Skeleton class for mappable undirected bipartite graphs.
|
deba@1018
|
1688 |
///
|
deba@1018
|
1689 |
/// This class describes the interface of mappable undirected
|
deba@1018
|
1690 |
/// bipartite graphs. It extends \ref MappableGraphComponent with
|
deba@1018
|
1691 |
/// the standard graph map class for red and blue nodes (\c
|
deba@1018
|
1692 |
/// RedMap and BlueMap). This concept is part of the BpGraph concept.
|
deba@1018
|
1693 |
template <typename BAS = BaseBpGraphComponent>
|
deba@1018
|
1694 |
class MappableBpGraphComponent : public MappableGraphComponent<BAS> {
|
deba@1018
|
1695 |
public:
|
deba@1018
|
1696 |
|
deba@1018
|
1697 |
typedef BAS Base;
|
deba@1018
|
1698 |
typedef typename Base::Node Node;
|
deba@1018
|
1699 |
|
deba@1018
|
1700 |
typedef MappableBpGraphComponent BpGraph;
|
deba@1018
|
1701 |
|
deba@1018
|
1702 |
/// \brief Standard graph map for the red nodes.
|
deba@1018
|
1703 |
///
|
deba@1018
|
1704 |
/// Standard graph map for the red nodes.
|
deba@1018
|
1705 |
/// It conforms to the ReferenceMap concept.
|
deba@1018
|
1706 |
template <typename V>
|
deba@1018
|
1707 |
class RedMap : public GraphMap<MappableBpGraphComponent, Node, V> {
|
deba@1018
|
1708 |
typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
|
deba@1018
|
1709 |
|
deba@1018
|
1710 |
public:
|
deba@1018
|
1711 |
/// \brief Construct a new map.
|
deba@1018
|
1712 |
///
|
deba@1018
|
1713 |
/// Construct a new map for the graph.
|
deba@1018
|
1714 |
explicit RedMap(const MappableBpGraphComponent& graph)
|
deba@1018
|
1715 |
: Parent(graph) {}
|
deba@1018
|
1716 |
|
deba@1018
|
1717 |
/// \brief Construct a new map with default value.
|
deba@1018
|
1718 |
///
|
deba@1018
|
1719 |
/// Construct a new map for the graph and initalize the values.
|
deba@1018
|
1720 |
RedMap(const MappableBpGraphComponent& graph, const V& value)
|
deba@1018
|
1721 |
: Parent(graph, value) {}
|
deba@1018
|
1722 |
|
deba@1018
|
1723 |
private:
|
deba@1018
|
1724 |
/// \brief Copy constructor.
|
deba@1018
|
1725 |
///
|
deba@1018
|
1726 |
/// Copy Constructor.
|
deba@1018
|
1727 |
RedMap(const RedMap& nm) : Parent(nm) {}
|
deba@1018
|
1728 |
|
deba@1018
|
1729 |
/// \brief Assignment operator.
|
deba@1018
|
1730 |
///
|
deba@1018
|
1731 |
/// Assignment operator.
|
deba@1018
|
1732 |
template <typename CMap>
|
deba@1018
|
1733 |
RedMap& operator=(const CMap&) {
|
deba@1018
|
1734 |
checkConcept<ReadMap<Node, V>, CMap>();
|
deba@1018
|
1735 |
return *this;
|
deba@1018
|
1736 |
}
|
deba@1018
|
1737 |
|
deba@1018
|
1738 |
};
|
deba@1018
|
1739 |
|
deba@1018
|
1740 |
/// \brief Standard graph map for the blue nodes.
|
deba@1018
|
1741 |
///
|
deba@1018
|
1742 |
/// Standard graph map for the blue nodes.
|
deba@1018
|
1743 |
/// It conforms to the ReferenceMap concept.
|
deba@1018
|
1744 |
template <typename V>
|
deba@1018
|
1745 |
class BlueMap : public GraphMap<MappableBpGraphComponent, Node, V> {
|
deba@1018
|
1746 |
typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
|
deba@1018
|
1747 |
|
deba@1018
|
1748 |
public:
|
deba@1018
|
1749 |
/// \brief Construct a new map.
|
deba@1018
|
1750 |
///
|
deba@1018
|
1751 |
/// Construct a new map for the graph.
|
deba@1018
|
1752 |
explicit BlueMap(const MappableBpGraphComponent& graph)
|
deba@1018
|
1753 |
: Parent(graph) {}
|
deba@1018
|
1754 |
|
deba@1018
|
1755 |
/// \brief Construct a new map with default value.
|
deba@1018
|
1756 |
///
|
deba@1018
|
1757 |
/// Construct a new map for the graph and initalize the values.
|
deba@1018
|
1758 |
BlueMap(const MappableBpGraphComponent& graph, const V& value)
|
deba@1018
|
1759 |
: Parent(graph, value) {}
|
deba@1018
|
1760 |
|
deba@1018
|
1761 |
private:
|
deba@1018
|
1762 |
/// \brief Copy constructor.
|
deba@1018
|
1763 |
///
|
deba@1018
|
1764 |
/// Copy Constructor.
|
deba@1018
|
1765 |
BlueMap(const BlueMap& nm) : Parent(nm) {}
|
deba@1018
|
1766 |
|
deba@1018
|
1767 |
/// \brief Assignment operator.
|
deba@1018
|
1768 |
///
|
deba@1018
|
1769 |
/// Assignment operator.
|
deba@1018
|
1770 |
template <typename CMap>
|
deba@1018
|
1771 |
BlueMap& operator=(const CMap&) {
|
deba@1018
|
1772 |
checkConcept<ReadMap<Node, V>, CMap>();
|
deba@1018
|
1773 |
return *this;
|
deba@1018
|
1774 |
}
|
deba@1018
|
1775 |
|
deba@1018
|
1776 |
};
|
deba@1018
|
1777 |
|
deba@1018
|
1778 |
|
deba@1018
|
1779 |
template <typename _BpGraph>
|
deba@1018
|
1780 |
struct Constraints {
|
deba@1018
|
1781 |
|
deba@1018
|
1782 |
struct Dummy {
|
deba@1018
|
1783 |
int value;
|
deba@1018
|
1784 |
Dummy() : value(0) {}
|
deba@1018
|
1785 |
Dummy(int _v) : value(_v) {}
|
deba@1018
|
1786 |
};
|
deba@1018
|
1787 |
|
deba@1018
|
1788 |
void constraints() {
|
deba@1018
|
1789 |
checkConcept<MappableGraphComponent<Base>, _BpGraph>();
|
deba@1018
|
1790 |
|
deba@1018
|
1791 |
{ // int map test
|
deba@1018
|
1792 |
typedef typename _BpGraph::template RedMap<int> IntRedMap;
|
deba@1018
|
1793 |
checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, int>,
|
deba@1018
|
1794 |
IntRedMap >();
|
deba@1018
|
1795 |
} { // bool map test
|
deba@1018
|
1796 |
typedef typename _BpGraph::template RedMap<bool> BoolRedMap;
|
deba@1018
|
1797 |
checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, bool>,
|
deba@1018
|
1798 |
BoolRedMap >();
|
deba@1018
|
1799 |
} { // Dummy map test
|
deba@1018
|
1800 |
typedef typename _BpGraph::template RedMap<Dummy> DummyRedMap;
|
deba@1018
|
1801 |
checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, Dummy>,
|
deba@1018
|
1802 |
DummyRedMap >();
|
deba@1018
|
1803 |
}
|
deba@1018
|
1804 |
|
deba@1018
|
1805 |
{ // int map test
|
deba@1018
|
1806 |
typedef typename _BpGraph::template BlueMap<int> IntBlueMap;
|
deba@1018
|
1807 |
checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, int>,
|
deba@1018
|
1808 |
IntBlueMap >();
|
deba@1018
|
1809 |
} { // bool map test
|
deba@1018
|
1810 |
typedef typename _BpGraph::template BlueMap<bool> BoolBlueMap;
|
deba@1018
|
1811 |
checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, bool>,
|
deba@1018
|
1812 |
BoolBlueMap >();
|
deba@1018
|
1813 |
} { // Dummy map test
|
deba@1018
|
1814 |
typedef typename _BpGraph::template BlueMap<Dummy> DummyBlueMap;
|
deba@1018
|
1815 |
checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, Dummy>,
|
deba@1018
|
1816 |
DummyBlueMap >();
|
deba@1018
|
1817 |
}
|
deba@1018
|
1818 |
}
|
deba@1018
|
1819 |
|
deba@1018
|
1820 |
const _BpGraph& bpgraph;
|
deba@1018
|
1821 |
};
|
deba@1018
|
1822 |
};
|
deba@1018
|
1823 |
|
kpeter@579
|
1824 |
/// \brief Skeleton class for extendable directed graphs.
|
deba@57
|
1825 |
///
|
kpeter@579
|
1826 |
/// This class describes the interface of extendable directed graphs.
|
alpar@877
|
1827 |
/// It extends \ref BaseDigraphComponent with functions for adding
|
kpeter@579
|
1828 |
/// nodes and arcs to the digraph.
|
kpeter@579
|
1829 |
/// This concept requires \ref AlterableDigraphComponent.
|
kpeter@559
|
1830 |
template <typename BAS = BaseDigraphComponent>
|
kpeter@559
|
1831 |
class ExtendableDigraphComponent : public BAS {
|
deba@57
|
1832 |
public:
|
kpeter@559
|
1833 |
typedef BAS Base;
|
deba@57
|
1834 |
|
kpeter@559
|
1835 |
typedef typename Base::Node Node;
|
kpeter@559
|
1836 |
typedef typename Base::Arc Arc;
|
deba@57
|
1837 |
|
kpeter@579
|
1838 |
/// \brief Add a new node to the digraph.
|
deba@57
|
1839 |
///
|
kpeter@579
|
1840 |
/// This function adds a new node to the digraph.
|
deba@57
|
1841 |
Node addNode() {
|
alpar@209
|
1842 |
return INVALID;
|
deba@57
|
1843 |
}
|
alpar@209
|
1844 |
|
kpeter@579
|
1845 |
/// \brief Add a new arc connecting the given two nodes.
|
deba@57
|
1846 |
///
|
kpeter@579
|
1847 |
/// This function adds a new arc connecting the given two nodes
|
kpeter@579
|
1848 |
/// of the digraph.
|
deba@57
|
1849 |
Arc addArc(const Node&, const Node&) {
|
alpar@209
|
1850 |
return INVALID;
|
deba@57
|
1851 |
}
|
deba@57
|
1852 |
|
deba@57
|
1853 |
template <typename _Digraph>
|
deba@57
|
1854 |
struct Constraints {
|
alpar@209
|
1855 |
void constraints() {
|
deba@57
|
1856 |
checkConcept<Base, _Digraph>();
|
alpar@209
|
1857 |
typename _Digraph::Node node_a, node_b;
|
alpar@209
|
1858 |
node_a = digraph.addNode();
|
alpar@209
|
1859 |
node_b = digraph.addNode();
|
alpar@209
|
1860 |
typename _Digraph::Arc arc;
|
alpar@209
|
1861 |
arc = digraph.addArc(node_a, node_b);
|
alpar@209
|
1862 |
}
|
deba@57
|
1863 |
|
alpar@209
|
1864 |
_Digraph& digraph;
|
alpar@975
|
1865 |
Constraints() {}
|
deba@57
|
1866 |
};
|
deba@57
|
1867 |
};
|
deba@57
|
1868 |
|
kpeter@579
|
1869 |
/// \brief Skeleton class for extendable undirected graphs.
|
deba@57
|
1870 |
///
|
kpeter@579
|
1871 |
/// This class describes the interface of extendable undirected graphs.
|
alpar@877
|
1872 |
/// It extends \ref BaseGraphComponent with functions for adding
|
kpeter@579
|
1873 |
/// nodes and edges to the graph.
|
kpeter@579
|
1874 |
/// This concept requires \ref AlterableGraphComponent.
|
kpeter@559
|
1875 |
template <typename BAS = BaseGraphComponent>
|
kpeter@559
|
1876 |
class ExtendableGraphComponent : public BAS {
|
deba@57
|
1877 |
public:
|
deba@57
|
1878 |
|
kpeter@559
|
1879 |
typedef BAS Base;
|
kpeter@559
|
1880 |
typedef typename Base::Node Node;
|
kpeter@559
|
1881 |
typedef typename Base::Edge Edge;
|
deba@57
|
1882 |
|
kpeter@579
|
1883 |
/// \brief Add a new node to the digraph.
|
deba@57
|
1884 |
///
|
kpeter@579
|
1885 |
/// This function adds a new node to the digraph.
|
deba@57
|
1886 |
Node addNode() {
|
alpar@209
|
1887 |
return INVALID;
|
deba@57
|
1888 |
}
|
alpar@209
|
1889 |
|
kpeter@579
|
1890 |
/// \brief Add a new edge connecting the given two nodes.
|
deba@57
|
1891 |
///
|
kpeter@579
|
1892 |
/// This function adds a new edge connecting the given two nodes
|
kpeter@579
|
1893 |
/// of the graph.
|
kpeter@579
|
1894 |
Edge addEdge(const Node&, const Node&) {
|
alpar@209
|
1895 |
return INVALID;
|
deba@57
|
1896 |
}
|
deba@57
|
1897 |
|
deba@57
|
1898 |
template <typename _Graph>
|
deba@57
|
1899 |
struct Constraints {
|
alpar@209
|
1900 |
void constraints() {
|
alpar@209
|
1901 |
checkConcept<Base, _Graph>();
|
alpar@209
|
1902 |
typename _Graph::Node node_a, node_b;
|
alpar@209
|
1903 |
node_a = graph.addNode();
|
alpar@209
|
1904 |
node_b = graph.addNode();
|
alpar@209
|
1905 |
typename _Graph::Edge edge;
|
alpar@209
|
1906 |
edge = graph.addEdge(node_a, node_b);
|
alpar@209
|
1907 |
}
|
deba@57
|
1908 |
|
alpar@209
|
1909 |
_Graph& graph;
|
alpar@975
|
1910 |
Constraints() {}
|
deba@57
|
1911 |
};
|
deba@57
|
1912 |
};
|
deba@57
|
1913 |
|
deba@1018
|
1914 |
/// \brief Skeleton class for extendable undirected bipartite graphs.
|
deba@1018
|
1915 |
///
|
deba@1018
|
1916 |
/// This class describes the interface of extendable undirected
|
deba@1018
|
1917 |
/// bipartite graphs. It extends \ref BaseGraphComponent with
|
deba@1018
|
1918 |
/// functions for adding nodes and edges to the graph. This
|
deba@1018
|
1919 |
/// concept requires \ref AlterableBpGraphComponent.
|
deba@1018
|
1920 |
template <typename BAS = BaseBpGraphComponent>
|
deba@1018
|
1921 |
class ExtendableBpGraphComponent : public BAS {
|
deba@1018
|
1922 |
public:
|
deba@1018
|
1923 |
|
deba@1018
|
1924 |
typedef BAS Base;
|
deba@1018
|
1925 |
typedef typename Base::Node Node;
|
deba@1018
|
1926 |
typedef typename Base::Edge Edge;
|
deba@1018
|
1927 |
|
deba@1018
|
1928 |
/// \brief Add a new red node to the digraph.
|
deba@1018
|
1929 |
///
|
deba@1018
|
1930 |
/// This function adds a red new node to the digraph.
|
deba@1018
|
1931 |
Node addRedNode() {
|
deba@1018
|
1932 |
return INVALID;
|
deba@1018
|
1933 |
}
|
deba@1018
|
1934 |
|
deba@1018
|
1935 |
/// \brief Add a new blue node to the digraph.
|
deba@1018
|
1936 |
///
|
deba@1018
|
1937 |
/// This function adds a blue new node to the digraph.
|
deba@1018
|
1938 |
Node addBlueNode() {
|
deba@1018
|
1939 |
return INVALID;
|
deba@1018
|
1940 |
}
|
deba@1018
|
1941 |
|
deba@1018
|
1942 |
/// \brief Add a new edge connecting the given two nodes.
|
deba@1018
|
1943 |
///
|
deba@1018
|
1944 |
/// This function adds a new edge connecting the given two nodes
|
deba@1018
|
1945 |
/// of the graph. The first node has to be a red node, and the
|
deba@1018
|
1946 |
/// second one a blue node.
|
deba@1018
|
1947 |
Edge addEdge(const Node&, const Node&) {
|
deba@1018
|
1948 |
return INVALID;
|
deba@1018
|
1949 |
}
|
deba@1018
|
1950 |
|
deba@1018
|
1951 |
template <typename _BpGraph>
|
deba@1018
|
1952 |
struct Constraints {
|
deba@1018
|
1953 |
void constraints() {
|
deba@1018
|
1954 |
checkConcept<Base, _BpGraph>();
|
deba@1018
|
1955 |
typename _BpGraph::Node red_node, blue_node;
|
deba@1018
|
1956 |
red_node = bpgraph.addRedNode();
|
deba@1018
|
1957 |
blue_node = bpgraph.addBlueNode();
|
deba@1018
|
1958 |
typename _BpGraph::Edge edge;
|
deba@1018
|
1959 |
edge = bpgraph.addEdge(red_node, blue_node);
|
deba@1018
|
1960 |
}
|
deba@1018
|
1961 |
|
deba@1018
|
1962 |
_BpGraph& bpgraph;
|
deba@1018
|
1963 |
};
|
deba@1018
|
1964 |
};
|
deba@1018
|
1965 |
|
kpeter@579
|
1966 |
/// \brief Skeleton class for erasable directed graphs.
|
alpar@209
|
1967 |
///
|
kpeter@579
|
1968 |
/// This class describes the interface of erasable directed graphs.
|
alpar@877
|
1969 |
/// It extends \ref BaseDigraphComponent with functions for removing
|
kpeter@579
|
1970 |
/// nodes and arcs from the digraph.
|
kpeter@579
|
1971 |
/// This concept requires \ref AlterableDigraphComponent.
|
kpeter@559
|
1972 |
template <typename BAS = BaseDigraphComponent>
|
kpeter@559
|
1973 |
class ErasableDigraphComponent : public BAS {
|
deba@57
|
1974 |
public:
|
deba@57
|
1975 |
|
kpeter@559
|
1976 |
typedef BAS Base;
|
deba@57
|
1977 |
typedef typename Base::Node Node;
|
deba@57
|
1978 |
typedef typename Base::Arc Arc;
|
deba@57
|
1979 |
|
deba@57
|
1980 |
/// \brief Erase a node from the digraph.
|
deba@57
|
1981 |
///
|
alpar@877
|
1982 |
/// This function erases the given node from the digraph and all arcs
|
kpeter@579
|
1983 |
/// connected to the node.
|
alpar@209
|
1984 |
void erase(const Node&) {}
|
deba@57
|
1985 |
|
deba@57
|
1986 |
/// \brief Erase an arc from the digraph.
|
deba@57
|
1987 |
///
|
kpeter@579
|
1988 |
/// This function erases the given arc from the digraph.
|
deba@57
|
1989 |
void erase(const Arc&) {}
|
deba@57
|
1990 |
|
deba@57
|
1991 |
template <typename _Digraph>
|
deba@57
|
1992 |
struct Constraints {
|
alpar@209
|
1993 |
void constraints() {
|
deba@57
|
1994 |
checkConcept<Base, _Digraph>();
|
kpeter@579
|
1995 |
const typename _Digraph::Node node(INVALID);
|
alpar@209
|
1996 |
digraph.erase(node);
|
kpeter@579
|
1997 |
const typename _Digraph::Arc arc(INVALID);
|
alpar@209
|
1998 |
digraph.erase(arc);
|
alpar@209
|
1999 |
}
|
deba@57
|
2000 |
|
alpar@209
|
2001 |
_Digraph& digraph;
|
alpar@975
|
2002 |
Constraints() {}
|
deba@57
|
2003 |
};
|
deba@57
|
2004 |
};
|
deba@57
|
2005 |
|
kpeter@579
|
2006 |
/// \brief Skeleton class for erasable undirected graphs.
|
alpar@209
|
2007 |
///
|
kpeter@579
|
2008 |
/// This class describes the interface of erasable undirected graphs.
|
alpar@877
|
2009 |
/// It extends \ref BaseGraphComponent with functions for removing
|
kpeter@579
|
2010 |
/// nodes and edges from the graph.
|
kpeter@579
|
2011 |
/// This concept requires \ref AlterableGraphComponent.
|
kpeter@559
|
2012 |
template <typename BAS = BaseGraphComponent>
|
kpeter@559
|
2013 |
class ErasableGraphComponent : public BAS {
|
deba@57
|
2014 |
public:
|
deba@57
|
2015 |
|
kpeter@559
|
2016 |
typedef BAS Base;
|
deba@57
|
2017 |
typedef typename Base::Node Node;
|
deba@57
|
2018 |
typedef typename Base::Edge Edge;
|
deba@57
|
2019 |
|
deba@57
|
2020 |
/// \brief Erase a node from the graph.
|
deba@57
|
2021 |
///
|
kpeter@579
|
2022 |
/// This function erases the given node from the graph and all edges
|
kpeter@579
|
2023 |
/// connected to the node.
|
alpar@209
|
2024 |
void erase(const Node&) {}
|
deba@57
|
2025 |
|
kpeter@579
|
2026 |
/// \brief Erase an edge from the digraph.
|
deba@57
|
2027 |
///
|
kpeter@579
|
2028 |
/// This function erases the given edge from the digraph.
|
deba@57
|
2029 |
void erase(const Edge&) {}
|
deba@57
|
2030 |
|
deba@57
|
2031 |
template <typename _Graph>
|
deba@57
|
2032 |
struct Constraints {
|
alpar@209
|
2033 |
void constraints() {
|
deba@57
|
2034 |
checkConcept<Base, _Graph>();
|
kpeter@579
|
2035 |
const typename _Graph::Node node(INVALID);
|
alpar@209
|
2036 |
graph.erase(node);
|
kpeter@579
|
2037 |
const typename _Graph::Edge edge(INVALID);
|
alpar@209
|
2038 |
graph.erase(edge);
|
alpar@209
|
2039 |
}
|
deba@57
|
2040 |
|
alpar@209
|
2041 |
_Graph& graph;
|
alpar@975
|
2042 |
Constraints() {}
|
deba@57
|
2043 |
};
|
deba@57
|
2044 |
};
|
deba@57
|
2045 |
|
deba@1018
|
2046 |
/// \brief Skeleton class for erasable undirected graphs.
|
deba@1018
|
2047 |
///
|
deba@1018
|
2048 |
/// This class describes the interface of erasable undirected
|
deba@1018
|
2049 |
/// bipartite graphs. It extends \ref BaseBpGraphComponent with
|
deba@1018
|
2050 |
/// functions for removing nodes and edges from the graph. This
|
deba@1018
|
2051 |
/// concept requires \ref AlterableBpGraphComponent.
|
deba@1018
|
2052 |
template <typename BAS = BaseBpGraphComponent>
|
deba@1018
|
2053 |
class ErasableBpGraphComponent : public ErasableGraphComponent<BAS> {};
|
deba@1018
|
2054 |
|
kpeter@579
|
2055 |
/// \brief Skeleton class for clearable directed graphs.
|
deba@57
|
2056 |
///
|
kpeter@579
|
2057 |
/// This class describes the interface of clearable directed graphs.
|
kpeter@579
|
2058 |
/// It extends \ref BaseDigraphComponent with a function for clearing
|
kpeter@579
|
2059 |
/// the digraph.
|
kpeter@579
|
2060 |
/// This concept requires \ref AlterableDigraphComponent.
|
kpeter@559
|
2061 |
template <typename BAS = BaseDigraphComponent>
|
kpeter@559
|
2062 |
class ClearableDigraphComponent : public BAS {
|
deba@57
|
2063 |
public:
|
deba@57
|
2064 |
|
kpeter@559
|
2065 |
typedef BAS Base;
|
deba@57
|
2066 |
|
deba@57
|
2067 |
/// \brief Erase all nodes and arcs from the digraph.
|
deba@57
|
2068 |
///
|
kpeter@579
|
2069 |
/// This function erases all nodes and arcs from the digraph.
|
alpar@209
|
2070 |
void clear() {}
|
deba@57
|
2071 |
|
deba@57
|
2072 |
template <typename _Digraph>
|
deba@57
|
2073 |
struct Constraints {
|
alpar@209
|
2074 |
void constraints() {
|
deba@57
|
2075 |
checkConcept<Base, _Digraph>();
|
alpar@209
|
2076 |
digraph.clear();
|
alpar@209
|
2077 |
}
|
deba@57
|
2078 |
|
kpeter@579
|
2079 |
_Digraph& digraph;
|
alpar@975
|
2080 |
Constraints() {}
|
deba@57
|
2081 |
};
|
deba@57
|
2082 |
};
|
deba@57
|
2083 |
|
kpeter@579
|
2084 |
/// \brief Skeleton class for clearable undirected graphs.
|
deba@57
|
2085 |
///
|
kpeter@579
|
2086 |
/// This class describes the interface of clearable undirected graphs.
|
kpeter@579
|
2087 |
/// It extends \ref BaseGraphComponent with a function for clearing
|
kpeter@579
|
2088 |
/// the graph.
|
kpeter@579
|
2089 |
/// This concept requires \ref AlterableGraphComponent.
|
kpeter@559
|
2090 |
template <typename BAS = BaseGraphComponent>
|
deba@1018
|
2091 |
class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {};
|
deba@57
|
2092 |
|
deba@1018
|
2093 |
/// \brief Skeleton class for clearable undirected biparite graphs.
|
deba@1018
|
2094 |
///
|
deba@1018
|
2095 |
/// This class describes the interface of clearable undirected
|
deba@1018
|
2096 |
/// bipartite graphs. It extends \ref BaseBpGraphComponent with a
|
deba@1018
|
2097 |
/// function for clearing the graph. This concept requires \ref
|
deba@1018
|
2098 |
/// AlterableBpGraphComponent.
|
deba@1018
|
2099 |
template <typename BAS = BaseBpGraphComponent>
|
deba@1018
|
2100 |
class ClearableBpGraphComponent : public ClearableGraphComponent<BAS> {};
|
deba@57
|
2101 |
|
deba@57
|
2102 |
}
|
deba@57
|
2103 |
|
deba@57
|
2104 |
}
|
deba@57
|
2105 |
|
deba@57
|
2106 |
#endif
|