klao@959
|
1 |
/* -*- C++ -*-
|
klao@959
|
2 |
* src/lemon/concept/graph_component.h - Part of LEMON, a generic C++ optimization library
|
klao@959
|
3 |
*
|
klao@959
|
4 |
* Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
klao@959
|
5 |
* (Egervary Combinatorial Optimization Research Group, EGRES).
|
klao@959
|
6 |
*
|
klao@959
|
7 |
* Permission to use, modify and distribute this software is granted
|
klao@959
|
8 |
* provided that this copyright notice appears in all copies. For
|
klao@959
|
9 |
* precise terms see the accompanying LICENSE file.
|
klao@959
|
10 |
*
|
klao@959
|
11 |
* This software is provided "AS IS" with no warranty of any kind,
|
klao@959
|
12 |
* express or implied, and with no claim as to its suitability for any
|
klao@959
|
13 |
* purpose.
|
klao@959
|
14 |
*
|
klao@959
|
15 |
*/
|
klao@959
|
16 |
|
klao@1030
|
17 |
///\ingroup graph_concepts
|
klao@959
|
18 |
///\file
|
klao@959
|
19 |
///\brief The graph components.
|
klao@959
|
20 |
|
klao@959
|
21 |
|
klao@959
|
22 |
#ifndef LEMON_CONCEPT_GRAPH_COMPONENT_H
|
klao@959
|
23 |
#define LEMON_CONCEPT_GRAPH_COMPONENT_H
|
klao@959
|
24 |
|
klao@959
|
25 |
#include <lemon/invalid.h>
|
klao@959
|
26 |
#include <lemon/concept/maps.h>
|
klao@959
|
27 |
|
deba@1134
|
28 |
#include <lemon/alteration_notifier.h>
|
deba@1134
|
29 |
|
klao@959
|
30 |
namespace lemon {
|
klao@959
|
31 |
namespace concept {
|
klao@959
|
32 |
|
klao@1030
|
33 |
/// \addtogroup graph_concepts
|
klao@1030
|
34 |
/// @{
|
klao@961
|
35 |
|
klao@961
|
36 |
/**************** Graph iterator concepts ****************/
|
klao@961
|
37 |
|
klao@1030
|
38 |
/// Skeleton class for graph Node and Edge types
|
klao@961
|
39 |
|
klao@1030
|
40 |
/// This class describes the interface of Node and Edge (and UndirEdge
|
klao@1030
|
41 |
/// in undirected graphs) subtypes of graph types.
|
klao@1030
|
42 |
///
|
klao@1030
|
43 |
/// \note This class is a template class so that we can use it to
|
klao@1030
|
44 |
/// create graph skeleton classes. The reason for this is than Node
|
klao@1030
|
45 |
/// and Edge types should \em not derive from the same base class.
|
klao@1030
|
46 |
/// For Node you should instantiate it with character 'n' and for Edge
|
klao@1030
|
47 |
/// with 'e'.
|
klao@961
|
48 |
|
klao@1030
|
49 |
#ifndef DOXYGEN
|
klao@1030
|
50 |
template <char _selector = '0'>
|
klao@1030
|
51 |
#endif
|
klao@961
|
52 |
class GraphItem {
|
klao@961
|
53 |
public:
|
deba@989
|
54 |
/// Default constructor.
|
deba@989
|
55 |
|
klao@1030
|
56 |
/// \warning The default constructor is not required to set
|
klao@1030
|
57 |
/// the item to some well-defined value. So you should consider it
|
klao@1030
|
58 |
/// as uninitialized.
|
klao@961
|
59 |
GraphItem() {}
|
deba@989
|
60 |
/// Copy constructor.
|
deba@989
|
61 |
|
deba@989
|
62 |
/// Copy constructor.
|
deba@989
|
63 |
///
|
deba@989
|
64 |
GraphItem(GraphItem const&) {}
|
deba@989
|
65 |
/// Invalid constructor \& conversion.
|
deba@989
|
66 |
|
deba@989
|
67 |
/// This constructor initializes the item to be invalid.
|
deba@989
|
68 |
/// \sa Invalid for more details.
|
klao@961
|
69 |
GraphItem(Invalid) {}
|
deba@989
|
70 |
/// Assign operator for nodes.
|
klao@961
|
71 |
|
deba@989
|
72 |
/// The nodes are assignable.
|
deba@989
|
73 |
///
|
klao@961
|
74 |
GraphItem& operator=(GraphItem const&) { return *this; }
|
deba@989
|
75 |
/// Equality operator.
|
deba@989
|
76 |
|
deba@989
|
77 |
/// Two iterators are equal if and only if they represents the
|
deba@989
|
78 |
/// same node in the graph or both are invalid.
|
klao@961
|
79 |
bool operator==(GraphItem) const { return false; }
|
deba@989
|
80 |
/// Inequality operator.
|
deba@989
|
81 |
|
deba@989
|
82 |
/// \sa operator==(const Node& n)
|
deba@989
|
83 |
///
|
klao@961
|
84 |
bool operator!=(GraphItem) const { return false; }
|
klao@961
|
85 |
|
klao@1030
|
86 |
/// Artificial ordering operator.
|
deba@989
|
87 |
|
klao@1030
|
88 |
/// To allow the use of graph descriptors as key type in std::map or
|
klao@1030
|
89 |
/// similar associative container we require this.
|
klao@1030
|
90 |
///
|
klao@1030
|
91 |
/// \note This operator only have to define some strict ordering of
|
klao@1030
|
92 |
/// the items; this order has nothing to do with the iteration
|
klao@1030
|
93 |
/// ordering of the items.
|
klao@1030
|
94 |
///
|
klao@1030
|
95 |
/// \bug This is a technical requirement. Do we really need this?
|
klao@1030
|
96 |
bool operator<(GraphItem) const { return false; }
|
deba@989
|
97 |
|
deba@989
|
98 |
template<typename _GraphItem>
|
deba@989
|
99 |
struct Constraints {
|
deba@989
|
100 |
void constraints() {
|
deba@989
|
101 |
_GraphItem i1;
|
deba@989
|
102 |
_GraphItem i2 = i1;
|
deba@989
|
103 |
_GraphItem i3 = INVALID;
|
deba@989
|
104 |
|
deba@989
|
105 |
i1 = i2 = i3;
|
deba@989
|
106 |
|
deba@989
|
107 |
bool b;
|
deba@989
|
108 |
// b = (ia == ib) && (ia != ib) && (ia < ib);
|
deba@989
|
109 |
b = (ia == ib) && (ia != ib);
|
deba@989
|
110 |
b = (ia == INVALID) && (ib != INVALID);
|
klao@1030
|
111 |
b = (ia < ib);
|
deba@989
|
112 |
}
|
deba@989
|
113 |
|
deba@989
|
114 |
const _GraphItem &ia;
|
deba@989
|
115 |
const _GraphItem &ib;
|
deba@989
|
116 |
};
|
klao@961
|
117 |
};
|
klao@961
|
118 |
|
klao@1030
|
119 |
/// A type describing the concept of graph node
|
klao@1030
|
120 |
|
klao@1030
|
121 |
/// This is an instantiation of \ref GraphItem which can be used as a
|
klao@1030
|
122 |
/// Node subtype in graph skeleton definitions
|
klao@1030
|
123 |
typedef GraphItem<'n'> GraphNode;
|
klao@1030
|
124 |
|
klao@1030
|
125 |
/// A type describing the concept of graph edge
|
klao@1030
|
126 |
|
klao@1030
|
127 |
/// This is an instantiation of \ref GraphItem which can be used as a
|
klao@1030
|
128 |
/// Edge subtype in graph skeleton definitions
|
klao@1030
|
129 |
typedef GraphItem<'e'> GraphEdge;
|
klao@1030
|
130 |
|
klao@1030
|
131 |
|
klao@1030
|
132 |
/**************** Basic features of graphs ****************/
|
klao@1030
|
133 |
|
klao@959
|
134 |
/// An empty base graph class.
|
klao@959
|
135 |
|
klao@961
|
136 |
/// This class provides the minimal set of features needed for a graph
|
klao@961
|
137 |
/// structure. All graph concepts have to be conform to this base
|
klao@961
|
138 |
/// graph.
|
klao@961
|
139 |
///
|
klao@961
|
140 |
/// \bug This is not true. The minimal graph concept is the
|
klao@961
|
141 |
/// BaseIterableGraphComponent.
|
klao@959
|
142 |
|
klao@959
|
143 |
class BaseGraphComponent {
|
klao@959
|
144 |
public:
|
klao@959
|
145 |
|
klao@959
|
146 |
typedef BaseGraphComponent Graph;
|
klao@959
|
147 |
|
klao@959
|
148 |
/// Node class of the graph.
|
klao@959
|
149 |
|
klao@959
|
150 |
/// This class represents the Nodes of the graph.
|
klao@959
|
151 |
///
|
deba@989
|
152 |
typedef GraphItem<'n'> Node;
|
klao@959
|
153 |
|
klao@959
|
154 |
/// Edge class of the graph.
|
klao@959
|
155 |
|
klao@959
|
156 |
/// This class represents the Edges of the graph.
|
klao@959
|
157 |
///
|
deba@989
|
158 |
typedef GraphItem<'e'> Edge;
|
klao@959
|
159 |
|
alpar@986
|
160 |
///Gives back the target node of an edge.
|
klao@959
|
161 |
|
alpar@986
|
162 |
///Gives back the target node of an edge.
|
klao@959
|
163 |
///
|
alpar@986
|
164 |
Node target(const Edge&) const { return INVALID;}
|
klao@959
|
165 |
|
alpar@986
|
166 |
///Gives back the source node of an edge.
|
klao@959
|
167 |
|
alpar@986
|
168 |
///Gives back the source node of an edge.
|
klao@959
|
169 |
///
|
alpar@986
|
170 |
Node source(const Edge&) const { return INVALID;}
|
klao@959
|
171 |
|
klao@961
|
172 |
|
deba@989
|
173 |
template <typename _Graph>
|
deba@989
|
174 |
struct Constraints {
|
deba@989
|
175 |
typedef typename _Graph::Node Node;
|
deba@989
|
176 |
typedef typename _Graph::Edge Edge;
|
klao@959
|
177 |
|
deba@989
|
178 |
void constraints() {
|
deba@989
|
179 |
checkConcept<GraphItem<'n'>, Node>();
|
deba@989
|
180 |
checkConcept<GraphItem<'e'>, Edge>();
|
deba@989
|
181 |
{
|
deba@989
|
182 |
Node n;
|
deba@989
|
183 |
Edge e;
|
deba@989
|
184 |
n = graph.source(e);
|
deba@989
|
185 |
n = graph.target(e);
|
deba@989
|
186 |
}
|
deba@989
|
187 |
}
|
klao@959
|
188 |
|
deba@989
|
189 |
const _Graph& graph;
|
deba@989
|
190 |
};
|
klao@959
|
191 |
};
|
klao@959
|
192 |
|
klao@959
|
193 |
/// An empty iterable base graph class.
|
klao@959
|
194 |
|
klao@959
|
195 |
/// This class provides beside the core graph features
|
klao@959
|
196 |
/// core iterable interface for the graph structure.
|
klao@959
|
197 |
/// Most of the base graphs should be conform to this concept.
|
klao@959
|
198 |
|
klao@959
|
199 |
class BaseIterableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
200 |
public:
|
klao@959
|
201 |
|
klao@959
|
202 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
203 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
204 |
|
klao@959
|
205 |
/// Gives back the first Node in the iterating order.
|
klao@959
|
206 |
|
klao@959
|
207 |
/// Gives back the first Node in the iterating order.
|
klao@959
|
208 |
///
|
klao@959
|
209 |
void first(Node&) const {}
|
klao@959
|
210 |
|
klao@959
|
211 |
/// Gives back the next Node in the iterating order.
|
klao@959
|
212 |
|
klao@959
|
213 |
/// Gives back the next Node in the iterating order.
|
klao@959
|
214 |
///
|
klao@959
|
215 |
void next(Node&) const {}
|
klao@959
|
216 |
|
klao@959
|
217 |
/// Gives back the first Edge in the iterating order.
|
klao@959
|
218 |
|
klao@959
|
219 |
/// Gives back the first Edge in the iterating order.
|
klao@959
|
220 |
///
|
klao@959
|
221 |
void first(Edge&) const {}
|
klao@959
|
222 |
/// Gives back the next Edge in the iterating order.
|
klao@959
|
223 |
|
klao@959
|
224 |
/// Gives back the next Edge in the iterating order.
|
klao@959
|
225 |
///
|
klao@959
|
226 |
void next(Edge&) const {}
|
klao@959
|
227 |
|
klao@959
|
228 |
|
klao@959
|
229 |
/// Gives back the first of the Edges point to the given Node.
|
klao@959
|
230 |
|
klao@959
|
231 |
/// Gives back the first of the Edges point to the given Node.
|
klao@959
|
232 |
///
|
klao@959
|
233 |
void firstIn(Edge&, const Node&) const {}
|
klao@959
|
234 |
|
klao@959
|
235 |
/// Gives back the next of the Edges points to the given Node.
|
klao@959
|
236 |
|
klao@959
|
237 |
|
klao@959
|
238 |
/// Gives back the next of the Edges points to the given Node.
|
klao@959
|
239 |
///
|
klao@959
|
240 |
void nextIn(Edge&) const {}
|
klao@959
|
241 |
|
klao@959
|
242 |
/// Gives back the first of the Edges start from the given Node.
|
klao@959
|
243 |
|
klao@959
|
244 |
/// Gives back the first of the Edges start from the given Node.
|
klao@959
|
245 |
///
|
klao@959
|
246 |
void firstOut(Edge&, const Node&) const {}
|
klao@959
|
247 |
|
klao@959
|
248 |
/// Gives back the next of the Edges start from the given Node.
|
klao@959
|
249 |
|
klao@959
|
250 |
/// Gives back the next of the Edges start from the given Node.
|
klao@959
|
251 |
///
|
klao@959
|
252 |
void nextOut(Edge&) const {}
|
klao@959
|
253 |
|
klao@959
|
254 |
|
deba@989
|
255 |
template <typename _Graph>
|
deba@989
|
256 |
struct Constraints {
|
deba@989
|
257 |
|
deba@989
|
258 |
void constraints() {
|
deba@989
|
259 |
checkConcept< BaseGraphComponent, _Graph >();
|
deba@989
|
260 |
typename _Graph::Node node;
|
deba@989
|
261 |
typename _Graph::Edge edge;
|
deba@989
|
262 |
{
|
deba@989
|
263 |
graph.first(node);
|
deba@989
|
264 |
graph.next(node);
|
deba@989
|
265 |
}
|
deba@989
|
266 |
{
|
deba@989
|
267 |
graph.first(edge);
|
deba@989
|
268 |
graph.next(edge);
|
deba@989
|
269 |
}
|
deba@989
|
270 |
{
|
deba@989
|
271 |
graph.firstIn(edge, node);
|
deba@989
|
272 |
graph.nextIn(edge);
|
deba@989
|
273 |
}
|
deba@989
|
274 |
{
|
deba@989
|
275 |
graph.firstOut(edge, node);
|
deba@989
|
276 |
graph.nextOut(edge);
|
deba@989
|
277 |
}
|
deba@989
|
278 |
}
|
klao@959
|
279 |
|
deba@989
|
280 |
const _Graph& graph;
|
deba@989
|
281 |
};
|
klao@959
|
282 |
};
|
klao@959
|
283 |
|
klao@959
|
284 |
/// An empty idable base graph class.
|
klao@959
|
285 |
|
klao@959
|
286 |
/// This class provides beside the core graph features
|
klao@959
|
287 |
/// core id functions for the graph structure.
|
klao@959
|
288 |
/// The most of the base graphs should be conform to this concept.
|
klao@959
|
289 |
/// The id's are unique and immutable.
|
klao@959
|
290 |
class IDableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
291 |
public:
|
klao@959
|
292 |
|
klao@959
|
293 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
294 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
295 |
|
klao@959
|
296 |
/// Gives back an unique integer id for the Node.
|
klao@959
|
297 |
|
klao@959
|
298 |
/// Gives back an unique integer id for the Node.
|
klao@959
|
299 |
///
|
klao@959
|
300 |
int id(const Node&) const { return -1;}
|
klao@959
|
301 |
|
deba@1106
|
302 |
/// \brief Gives back the node by the unique id.
|
deba@1106
|
303 |
///
|
deba@1106
|
304 |
/// Gives back the node by the unique id.
|
deba@1106
|
305 |
/// If the graph does not contain node with the given id
|
deba@1106
|
306 |
/// then the result of the function is undetermined.
|
deba@1106
|
307 |
Node fromId(int id, Node) const { return INVALID;}
|
klao@959
|
308 |
|
deba@1106
|
309 |
/// \brief Gives back an unique integer id for the Edge.
|
deba@1106
|
310 |
///
|
klao@959
|
311 |
/// Gives back an unique integer id for the Edge.
|
klao@959
|
312 |
///
|
klao@959
|
313 |
int id(const Edge&) const { return -1;}
|
klao@959
|
314 |
|
deba@1106
|
315 |
/// \brief Gives back the edge by the unique id.
|
deba@1106
|
316 |
///
|
deba@1106
|
317 |
/// Gives back the edge by the unique id.
|
deba@1106
|
318 |
/// If the graph does not contain edge with the given id
|
deba@1106
|
319 |
/// then the result of the function is undetermined.
|
deba@1106
|
320 |
Edge fromId(int id, Edge) const { return INVALID;}
|
deba@1106
|
321 |
|
deba@989
|
322 |
template <typename _Graph>
|
deba@989
|
323 |
struct Constraints {
|
klao@959
|
324 |
|
deba@989
|
325 |
void constraints() {
|
deba@989
|
326 |
checkConcept< BaseGraphComponent, _Graph >();
|
deba@989
|
327 |
typename _Graph::Node node;
|
deba@989
|
328 |
int nid = graph.id(node);
|
deba@989
|
329 |
nid = graph.id(node);
|
deba@1106
|
330 |
node = graph.fromId(nid, Node());
|
deba@989
|
331 |
typename _Graph::Edge edge;
|
deba@989
|
332 |
int eid = graph.id(edge);
|
deba@989
|
333 |
eid = graph.id(edge);
|
deba@1106
|
334 |
edge = graph.fromId(eid, Edge());
|
deba@989
|
335 |
}
|
klao@959
|
336 |
|
deba@989
|
337 |
const _Graph& graph;
|
deba@989
|
338 |
};
|
klao@959
|
339 |
};
|
klao@959
|
340 |
|
klao@959
|
341 |
|
klao@959
|
342 |
/// An empty max-idable base graph class.
|
klao@959
|
343 |
|
klao@959
|
344 |
/// This class provides beside the core graph features
|
klao@959
|
345 |
/// core max id functions for the graph structure.
|
klao@959
|
346 |
/// The most of the base graphs should be conform to this concept.
|
klao@959
|
347 |
/// The id's are unique and immutable.
|
klao@959
|
348 |
class MaxIDableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
349 |
public:
|
klao@959
|
350 |
|
klao@959
|
351 |
/// Gives back an integer greater or equal to the maximum Node id.
|
klao@959
|
352 |
|
klao@959
|
353 |
/// Gives back an integer greater or equal to the maximum Node id.
|
klao@959
|
354 |
///
|
deba@980
|
355 |
int maxId(Node = INVALID) const { return -1;}
|
klao@959
|
356 |
|
klao@959
|
357 |
/// Gives back an integer greater or equal to the maximum Edge id.
|
klao@959
|
358 |
|
klao@959
|
359 |
/// Gives back an integer greater or equal to the maximum Edge id.
|
klao@959
|
360 |
///
|
deba@980
|
361 |
int maxId(Edge = INVALID) const { return -1;}
|
klao@959
|
362 |
|
deba@989
|
363 |
template <typename _Graph>
|
deba@989
|
364 |
struct Constraints {
|
klao@959
|
365 |
|
deba@989
|
366 |
void constraints() {
|
deba@989
|
367 |
checkConcept<BaseGraphComponent, _Graph>();
|
deba@989
|
368 |
int nid = graph.maxId(typename _Graph::Node());
|
deba@989
|
369 |
ignore_unused_variable_warning(nid);
|
deba@989
|
370 |
int eid = graph.maxId(typename _Graph::Edge());
|
deba@989
|
371 |
ignore_unused_variable_warning(eid);
|
deba@989
|
372 |
}
|
deba@989
|
373 |
|
deba@989
|
374 |
const _Graph& graph;
|
deba@989
|
375 |
};
|
klao@959
|
376 |
};
|
klao@959
|
377 |
|
klao@959
|
378 |
/// An empty extendable base graph class.
|
klao@959
|
379 |
|
klao@959
|
380 |
/// This class provides beside the core graph features
|
klao@959
|
381 |
/// core graph extend interface for the graph structure.
|
klao@959
|
382 |
/// The most of the base graphs should be conform to this concept.
|
klao@959
|
383 |
class BaseExtendableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
384 |
public:
|
klao@959
|
385 |
|
klao@959
|
386 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
387 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
388 |
|
klao@959
|
389 |
/// Adds a new Node to the graph.
|
klao@959
|
390 |
|
klao@959
|
391 |
/// Adds a new Node to the graph.
|
klao@959
|
392 |
///
|
klao@959
|
393 |
Node addNode() {
|
klao@959
|
394 |
return INVALID;
|
klao@959
|
395 |
}
|
klao@959
|
396 |
|
klao@959
|
397 |
/// Adds a new Edge connects the two Nodes to the graph.
|
klao@959
|
398 |
|
klao@959
|
399 |
/// Adds a new Edge connects the two Nodes to the graph.
|
klao@959
|
400 |
///
|
klao@959
|
401 |
Edge addEdge(const Node& from, const Node& to) {
|
klao@959
|
402 |
return INVALID;
|
klao@959
|
403 |
}
|
klao@959
|
404 |
|
deba@989
|
405 |
template <typename _Graph>
|
deba@989
|
406 |
struct Constraints {
|
deba@989
|
407 |
void constraints() {
|
deba@989
|
408 |
checkConcept<BaseGraphComponent, _Graph >();
|
deba@989
|
409 |
typename _Graph::Node node_a, node_b;
|
deba@989
|
410 |
node_a = graph.addNode();
|
deba@989
|
411 |
typename _Graph::Edge edge;
|
deba@989
|
412 |
edge = graph.addEdge(node_a, node_b);
|
deba@989
|
413 |
}
|
klao@959
|
414 |
|
deba@989
|
415 |
_Graph& graph;
|
deba@989
|
416 |
};
|
klao@959
|
417 |
};
|
klao@959
|
418 |
|
klao@959
|
419 |
/// An empty erasable base graph class.
|
klao@959
|
420 |
|
klao@959
|
421 |
/// This class provides beside the core graph features
|
klao@959
|
422 |
/// core erase functions for the graph structure.
|
klao@959
|
423 |
/// The most of the base graphs should be conform to this concept.
|
klao@959
|
424 |
class BaseErasableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
425 |
public:
|
klao@959
|
426 |
|
klao@959
|
427 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
428 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
429 |
|
klao@959
|
430 |
/// Erase a Node from the graph.
|
klao@959
|
431 |
|
klao@959
|
432 |
/// Erase a Node from the graph. This function should not
|
klao@959
|
433 |
/// erase edges connecting to the Node.
|
klao@959
|
434 |
void erase(const Node&) {}
|
klao@959
|
435 |
|
klao@959
|
436 |
/// Erase an Edge from the graph.
|
klao@959
|
437 |
|
klao@959
|
438 |
/// Erase an Edge from the graph.
|
klao@959
|
439 |
///
|
klao@959
|
440 |
void erase(const Edge&) {}
|
klao@959
|
441 |
|
deba@989
|
442 |
template <typename _Graph>
|
deba@989
|
443 |
struct Constraints {
|
deba@989
|
444 |
void constraints() {
|
deba@989
|
445 |
checkConcept<BaseGraphComponent, _Graph>();
|
deba@989
|
446 |
typename _Graph::Node node;
|
deba@989
|
447 |
graph.erase(node);
|
deba@989
|
448 |
typename _Graph::Edge edge;
|
deba@989
|
449 |
graph.erase(edge);
|
deba@989
|
450 |
}
|
klao@959
|
451 |
|
deba@989
|
452 |
_Graph& graph;
|
deba@989
|
453 |
};
|
klao@959
|
454 |
};
|
klao@959
|
455 |
|
klao@959
|
456 |
/// An empty clearable base graph class.
|
klao@959
|
457 |
|
klao@959
|
458 |
/// This class provides beside the core graph features
|
klao@959
|
459 |
/// core clear functions for the graph structure.
|
klao@959
|
460 |
/// The most of the base graphs should be conform to this concept.
|
klao@1022
|
461 |
class ClearableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
462 |
public:
|
klao@959
|
463 |
|
klao@959
|
464 |
/// Erase all the Nodes and Edges from the graph.
|
klao@959
|
465 |
|
klao@959
|
466 |
/// Erase all the Nodes and Edges from the graph.
|
klao@959
|
467 |
///
|
klao@959
|
468 |
void clear() {}
|
deba@989
|
469 |
|
deba@989
|
470 |
template <typename _Graph>
|
deba@989
|
471 |
struct Constraints {
|
deba@989
|
472 |
void constraints() {
|
klao@1022
|
473 |
checkConcept<BaseGraphComponent, _Graph>();
|
deba@989
|
474 |
graph.clear();
|
deba@989
|
475 |
}
|
deba@989
|
476 |
|
klao@1022
|
477 |
_Graph graph;
|
deba@989
|
478 |
};
|
klao@959
|
479 |
};
|
klao@959
|
480 |
|
klao@959
|
481 |
|
deba@989
|
482 |
/// Skeleton class for graph NodeIt and EdgeIt
|
deba@989
|
483 |
|
deba@989
|
484 |
/// Skeleton class for graph NodeIt and EdgeIt.
|
klao@959
|
485 |
///
|
deba@989
|
486 |
template <typename _Graph, typename _Item>
|
deba@989
|
487 |
class GraphIterator : public _Item {
|
deba@989
|
488 |
public:
|
deba@989
|
489 |
/// \todo Don't we need the Item type as typedef?
|
klao@959
|
490 |
|
deba@989
|
491 |
/// Default constructor.
|
deba@989
|
492 |
|
deba@989
|
493 |
/// @warning The default constructor sets the iterator
|
deba@989
|
494 |
/// to an undefined value.
|
deba@989
|
495 |
GraphIterator() {}
|
deba@989
|
496 |
/// Copy constructor.
|
deba@989
|
497 |
|
deba@989
|
498 |
/// Copy constructor.
|
deba@989
|
499 |
///
|
deba@989
|
500 |
GraphIterator(GraphIterator const&) {}
|
deba@989
|
501 |
/// Sets the iterator to the first item.
|
deba@989
|
502 |
|
deba@989
|
503 |
/// Sets the iterator to the first item of \c the graph.
|
deba@989
|
504 |
///
|
deba@989
|
505 |
explicit GraphIterator(const _Graph&) {}
|
deba@989
|
506 |
/// Invalid constructor \& conversion.
|
deba@989
|
507 |
|
deba@989
|
508 |
/// This constructor initializes the item to be invalid.
|
deba@989
|
509 |
/// \sa Invalid for more details.
|
deba@989
|
510 |
GraphIterator(Invalid) {}
|
deba@989
|
511 |
/// Assign operator for items.
|
deba@989
|
512 |
|
deba@989
|
513 |
/// The items are assignable.
|
deba@989
|
514 |
///
|
deba@989
|
515 |
GraphIterator& operator=(GraphIterator const&) { return *this; }
|
deba@989
|
516 |
/// Next item.
|
deba@989
|
517 |
|
deba@989
|
518 |
/// Assign the iterator to the next item.
|
deba@989
|
519 |
///
|
deba@989
|
520 |
GraphIterator& operator++() { return *this; }
|
deba@989
|
521 |
// Node operator*() const { return INVALID; }
|
deba@989
|
522 |
/// Equality operator
|
deba@989
|
523 |
|
deba@989
|
524 |
/// Two iterators are equal if and only if they point to the
|
deba@989
|
525 |
/// same object or both are invalid.
|
deba@989
|
526 |
bool operator==(const GraphIterator&) const { return true;}
|
deba@989
|
527 |
/// Inequality operator
|
deba@989
|
528 |
|
deba@989
|
529 |
/// \sa operator==(Node n)
|
deba@989
|
530 |
///
|
deba@989
|
531 |
bool operator!=(const GraphIterator&) const { return true;}
|
deba@989
|
532 |
|
deba@989
|
533 |
template<typename _GraphIterator>
|
deba@989
|
534 |
struct Constraints {
|
deba@989
|
535 |
void constraints() {
|
deba@989
|
536 |
// checkConcept< Item, _GraphIterator >();
|
deba@989
|
537 |
_GraphIterator it1(g);
|
deba@989
|
538 |
|
deba@989
|
539 |
/// \todo Do we need NodeIt(Node) kind of constructor?
|
deba@989
|
540 |
// _GraphIterator it2(bj);
|
deba@989
|
541 |
_GraphIterator it2;
|
deba@989
|
542 |
|
deba@989
|
543 |
it2 = ++it1;
|
deba@989
|
544 |
++it2 = it1;
|
deba@989
|
545 |
++(++it1);
|
deba@989
|
546 |
/// \bug This should be: is_base_and_derived<BaseItem, _GraphIterator>
|
deba@989
|
547 |
_Item bi = it1;
|
deba@989
|
548 |
bi = it2;
|
deba@989
|
549 |
}
|
deba@989
|
550 |
_Graph& g;
|
deba@989
|
551 |
};
|
klao@959
|
552 |
};
|
klao@959
|
553 |
|
deba@989
|
554 |
/// Skeleton class for graph InEdgeIt and OutEdgeIt
|
klao@959
|
555 |
|
deba@989
|
556 |
/// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
|
deba@989
|
557 |
/// base class, the _selector is a additional template parameter. For
|
deba@989
|
558 |
/// InEdgeIt you should instantiate it with character 'i' and for
|
deba@989
|
559 |
/// OutEdgeIt with 'o'.
|
klao@1021
|
560 |
/// \todo Is this a good name for this concept?
|
klao@1021
|
561 |
template <typename Graph,
|
klao@1021
|
562 |
typename Edge = typename Graph::Edge,
|
klao@1021
|
563 |
char _selector = '0'>
|
klao@1021
|
564 |
class GraphIncIterator : public Edge {
|
deba@989
|
565 |
public:
|
deba@989
|
566 |
/// Default constructor.
|
deba@989
|
567 |
|
deba@989
|
568 |
/// @warning The default constructor sets the iterator
|
deba@989
|
569 |
/// to an undefined value.
|
klao@1021
|
570 |
GraphIncIterator() {}
|
deba@989
|
571 |
/// Copy constructor.
|
deba@989
|
572 |
|
deba@989
|
573 |
/// Copy constructor.
|
deba@989
|
574 |
///
|
klao@1021
|
575 |
GraphIncIterator(GraphIncIterator const&) {}
|
deba@1134
|
576 |
/// Sets the iterator to the first edge incoming into or outgoing
|
deba@1134
|
577 |
/// from the node.
|
deba@989
|
578 |
|
deba@1134
|
579 |
/// Sets the iterator to the first edge incoming into or outgoing
|
deba@1134
|
580 |
/// from the node.
|
deba@989
|
581 |
///
|
klao@1021
|
582 |
explicit GraphIncIterator(const Graph&, const typename Graph::Node&) {}
|
deba@989
|
583 |
/// Invalid constructor \& conversion.
|
deba@989
|
584 |
|
deba@989
|
585 |
/// This constructor initializes the item to be invalid.
|
deba@989
|
586 |
/// \sa Invalid for more details.
|
klao@1021
|
587 |
GraphIncIterator(Invalid) {}
|
deba@989
|
588 |
/// Assign operator for nodes.
|
deba@989
|
589 |
|
deba@989
|
590 |
/// The nodes are assignable.
|
deba@989
|
591 |
///
|
klao@1021
|
592 |
GraphIncIterator& operator=(GraphIncIterator const&) { return *this; }
|
deba@989
|
593 |
/// Next edge.
|
deba@989
|
594 |
|
deba@989
|
595 |
/// Assign the iterator to the next node.
|
deba@989
|
596 |
///
|
klao@1021
|
597 |
GraphIncIterator& operator++() { return *this; }
|
klao@1021
|
598 |
|
deba@989
|
599 |
// Node operator*() const { return INVALID; }
|
klao@1021
|
600 |
|
deba@989
|
601 |
/// Equality operator
|
deba@989
|
602 |
|
deba@989
|
603 |
/// Two iterators are equal if and only if they point to the
|
deba@989
|
604 |
/// same object or both are invalid.
|
klao@1021
|
605 |
bool operator==(const GraphIncIterator&) const { return true;}
|
klao@1021
|
606 |
|
deba@989
|
607 |
/// Inequality operator
|
deba@989
|
608 |
|
deba@989
|
609 |
/// \sa operator==(Node n)
|
deba@989
|
610 |
///
|
klao@1021
|
611 |
bool operator!=(const GraphIncIterator&) const { return true;}
|
deba@989
|
612 |
|
klao@1021
|
613 |
template <typename _GraphIncIterator>
|
deba@989
|
614 |
struct Constraints {
|
klao@1021
|
615 |
typedef typename Graph::Node Node;
|
deba@989
|
616 |
void constraints() {
|
klao@1021
|
617 |
checkConcept<GraphItem<'e'>, _GraphIncIterator>();
|
klao@1021
|
618 |
_GraphIncIterator it1(graph, node);
|
deba@989
|
619 |
/// \todo Do we need OutEdgeIt(Edge) kind of constructor?
|
klao@1021
|
620 |
// _GraphIncIterator it2(edge);
|
klao@1021
|
621 |
_GraphIncIterator it2;
|
deba@989
|
622 |
|
deba@989
|
623 |
it2 = ++it1;
|
deba@989
|
624 |
++it2 = it1;
|
deba@989
|
625 |
++(++it1);
|
deba@989
|
626 |
Edge e = it1;
|
deba@989
|
627 |
e = it2;
|
deba@989
|
628 |
}
|
deba@989
|
629 |
|
deba@989
|
630 |
Edge& edge;
|
deba@989
|
631 |
Node& node;
|
klao@1021
|
632 |
Graph& graph;
|
deba@989
|
633 |
};
|
deba@989
|
634 |
};
|
klao@1021
|
635 |
|
klao@1021
|
636 |
|
deba@989
|
637 |
/// An empty iterable base graph class.
|
deba@989
|
638 |
|
deba@989
|
639 |
/// This class provides beside the core graph features
|
deba@989
|
640 |
/// iterator based iterable interface for the graph structure.
|
deba@989
|
641 |
/// This concept is part of the StaticGraphConcept.
|
deba@989
|
642 |
class IterableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
643 |
|
klao@959
|
644 |
public:
|
klao@959
|
645 |
|
klao@959
|
646 |
typedef IterableGraphComponent Graph;
|
klao@959
|
647 |
|
klao@959
|
648 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
649 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
650 |
|
deba@989
|
651 |
/// This iterator goes through each node.
|
klao@959
|
652 |
|
deba@989
|
653 |
/// This iterator goes through each node.
|
deba@989
|
654 |
///
|
deba@989
|
655 |
typedef GraphIterator<Graph, Node> NodeIt;
|
deba@989
|
656 |
/// This iterator goes through each node.
|
klao@959
|
657 |
|
deba@989
|
658 |
/// This iterator goes through each node.
|
deba@989
|
659 |
///
|
deba@989
|
660 |
typedef GraphIterator<Graph, Edge> EdgeIt;
|
deba@989
|
661 |
/// This iterator goes trough the incoming edges of a node.
|
klao@959
|
662 |
|
deba@989
|
663 |
/// This iterator goes trough the \e inccoming edges of a certain node
|
deba@989
|
664 |
/// of a graph.
|
klao@1021
|
665 |
typedef GraphIncIterator<Graph, Edge, 'i'> InEdgeIt;
|
deba@989
|
666 |
/// This iterator goes trough the outgoing edges of a node.
|
klao@959
|
667 |
|
deba@989
|
668 |
/// This iterator goes trough the \e outgoing edges of a certain node
|
deba@989
|
669 |
/// of a graph.
|
klao@1021
|
670 |
typedef GraphIncIterator<Graph, Edge, 'o'> OutEdgeIt;
|
deba@989
|
671 |
};
|
deba@989
|
672 |
|
deba@989
|
673 |
template <typename _Graph>
|
deba@989
|
674 |
struct Constraints {
|
deba@989
|
675 |
void constraints() {
|
deba@989
|
676 |
checkConcept< BaseGraphComponent, _Graph>();
|
klao@959
|
677 |
|
deba@1134
|
678 |
checkConcept<GraphIterator<_Graph, typename _Graph::Edge>,
|
deba@1134
|
679 |
typename _Graph::EdgeIt >();
|
deba@1134
|
680 |
checkConcept<GraphIterator<_Graph, typename _Graph::Node>,
|
deba@1134
|
681 |
typename _Graph::NodeIt >();
|
klao@1021
|
682 |
checkConcept<GraphIncIterator<_Graph>, typename _Graph::InEdgeIt >();
|
klao@1021
|
683 |
checkConcept<GraphIncIterator<_Graph>, typename _Graph::OutEdgeIt >();
|
deba@989
|
684 |
}
|
deba@989
|
685 |
};
|
klao@959
|
686 |
|
deba@1134
|
687 |
/// An empty alteration notifier base graph class.
|
deba@1134
|
688 |
|
deba@1134
|
689 |
/// This class provides beside the core graph features
|
deba@1134
|
690 |
/// alteration notifier interface for the graph structure.
|
deba@1134
|
691 |
/// This is an observer-notifier pattern. More Obsevers can
|
deba@1134
|
692 |
/// be registered into the notifier and whenever an alteration
|
deba@1134
|
693 |
/// occured in the graph all the observers will notified about it.
|
deba@1134
|
694 |
class AlterableGraphComponent : virtual public BaseGraphComponent {
|
deba@1134
|
695 |
public:
|
deba@1134
|
696 |
|
deba@1134
|
697 |
/// The edge observer registry.
|
deba@1134
|
698 |
typedef AlterationNotifier<Edge> EdgeNotifier;
|
deba@1134
|
699 |
/// The node observer registry.
|
deba@1134
|
700 |
typedef AlterationNotifier<Node> NodeNotifier;
|
deba@1134
|
701 |
|
deba@1134
|
702 |
/// \brief Gives back the edge alteration notifier.
|
deba@1134
|
703 |
///
|
deba@1134
|
704 |
/// Gives back the edge alteration notifier.
|
deba@1134
|
705 |
EdgeNotifier getNotifier(Edge) const {
|
deba@1134
|
706 |
return EdgeNotifier();
|
deba@1134
|
707 |
}
|
deba@1134
|
708 |
|
deba@1134
|
709 |
/// \brief Gives back the node alteration notifier.
|
deba@1134
|
710 |
///
|
deba@1134
|
711 |
/// Gives back the node alteration notifier.
|
deba@1134
|
712 |
NodeNotifier getNotifier(Node) const {
|
deba@1134
|
713 |
return NodeNotifier();
|
deba@1134
|
714 |
}
|
deba@1134
|
715 |
|
deba@1134
|
716 |
};
|
deba@1134
|
717 |
|
klao@959
|
718 |
|
klao@1030
|
719 |
/// Class describing the concept of graph maps
|
klao@1030
|
720 |
|
klao@1030
|
721 |
/// This class describes the common interface of the graph maps
|
alpar@1043
|
722 |
/// (NodeMap, EdgeMap), that is \ref maps-pages "maps" which can be used to
|
klao@1030
|
723 |
/// associate data to graph descriptors (nodes or edges).
|
deba@989
|
724 |
template <typename Graph, typename Item, typename _Value>
|
deba@989
|
725 |
class GraphMap : public ReadWriteMap<Item, _Value> {
|
deba@989
|
726 |
protected:
|
deba@989
|
727 |
GraphMap() {}
|
deba@989
|
728 |
public:
|
deba@1134
|
729 |
/// \brief Construct a new map.
|
deba@1134
|
730 |
///
|
deba@1134
|
731 |
/// Construct a new map for the graph.
|
deba@989
|
732 |
explicit GraphMap(const Graph&) {}
|
deba@1134
|
733 |
/// \brief Construct a new map with default value.
|
deba@1134
|
734 |
///
|
deba@1134
|
735 |
/// Construct a new map for the graph and initalise the values.
|
deba@989
|
736 |
GraphMap(const Graph&, const _Value&) {}
|
deba@1134
|
737 |
/// \brief Copy constructor.
|
deba@1134
|
738 |
///
|
deba@1134
|
739 |
/// Copy Constructor.
|
deba@989
|
740 |
GraphMap(const GraphMap&) {}
|
deba@989
|
741 |
|
deba@1134
|
742 |
/// \brief Assign operator.
|
deba@1134
|
743 |
///
|
deba@1134
|
744 |
/// Assign operator.
|
deba@989
|
745 |
GraphMap& operator=(const GraphMap&) { return *this;}
|
klao@959
|
746 |
|
deba@989
|
747 |
template<typename _Map>
|
deba@989
|
748 |
struct Constraints {
|
deba@989
|
749 |
void constraints() {
|
deba@989
|
750 |
checkConcept<ReadWriteMap<Item, _Value>, _Map >();
|
deba@989
|
751 |
// Construction with a graph parameter
|
deba@989
|
752 |
_Map a(g);
|
deba@989
|
753 |
// Constructor with a graph and a default value parameter
|
deba@989
|
754 |
_Map a2(g,t);
|
deba@989
|
755 |
// Copy constructor. Do we need it?
|
deba@989
|
756 |
_Map b=c;
|
deba@989
|
757 |
// Copy operator. Do we need it?
|
deba@989
|
758 |
a=b;
|
klao@959
|
759 |
|
deba@989
|
760 |
ignore_unused_variable_warning(a2);
|
deba@989
|
761 |
}
|
klao@959
|
762 |
|
deba@989
|
763 |
const _Map &c;
|
deba@989
|
764 |
const Graph &g;
|
deba@989
|
765 |
const typename GraphMap::Value &t;
|
klao@959
|
766 |
};
|
klao@959
|
767 |
|
klao@959
|
768 |
};
|
klao@961
|
769 |
|
deba@989
|
770 |
/// An empty mappable base graph class.
|
klao@959
|
771 |
|
deba@989
|
772 |
/// This class provides beside the core graph features
|
deba@989
|
773 |
/// map interface for the graph structure.
|
deba@989
|
774 |
/// This concept is part of the StaticGraphConcept.
|
klao@959
|
775 |
class MappableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
776 |
public:
|
klao@959
|
777 |
|
klao@959
|
778 |
typedef MappableGraphComponent Graph;
|
klao@959
|
779 |
|
klao@959
|
780 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
781 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
782 |
|
deba@989
|
783 |
/// ReadWrite map of the nodes.
|
deba@989
|
784 |
|
deba@989
|
785 |
/// ReadWrite map of the nodes.
|
deba@989
|
786 |
///
|
alpar@987
|
787 |
template <typename _Value>
|
deba@989
|
788 |
class NodeMap : public GraphMap<Graph, Node, _Value> {
|
deba@989
|
789 |
private:
|
deba@989
|
790 |
NodeMap();
|
klao@959
|
791 |
public:
|
deba@1134
|
792 |
/// \brief Construct a new map.
|
deba@1134
|
793 |
///
|
deba@1134
|
794 |
/// Construct a new map for the graph.
|
deba@1134
|
795 |
/// \todo call the right parent class constructor
|
deba@989
|
796 |
explicit NodeMap(const Graph&) {}
|
deba@1134
|
797 |
/// \brief Construct a new map with default value.
|
deba@1134
|
798 |
///
|
deba@1134
|
799 |
/// Construct a new map for the graph and initalise the values.
|
alpar@987
|
800 |
NodeMap(const Graph&, const _Value&) {}
|
deba@1134
|
801 |
/// \brief Copy constructor.
|
deba@1134
|
802 |
///
|
deba@1134
|
803 |
/// Copy Constructor.
|
klao@959
|
804 |
NodeMap(const NodeMap&) {}
|
klao@959
|
805 |
|
deba@1134
|
806 |
/// \brief Assign operator.
|
deba@1134
|
807 |
///
|
deba@1134
|
808 |
/// Assign operator.
|
klao@959
|
809 |
NodeMap& operator=(const NodeMap&) { return *this;}
|
deba@989
|
810 |
|
klao@959
|
811 |
};
|
klao@959
|
812 |
|
deba@989
|
813 |
/// ReadWrite map of the edges.
|
deba@989
|
814 |
|
deba@989
|
815 |
/// ReadWrite map of the edges.
|
deba@989
|
816 |
///
|
alpar@987
|
817 |
template <typename _Value>
|
deba@989
|
818 |
class EdgeMap : public GraphMap<Graph, Edge, _Value> {
|
deba@989
|
819 |
private:
|
deba@989
|
820 |
EdgeMap();
|
klao@959
|
821 |
public:
|
deba@1134
|
822 |
/// \brief Construct a new map.
|
deba@1134
|
823 |
///
|
deba@1134
|
824 |
/// Construct a new map for the graph.
|
deba@1134
|
825 |
/// \todo call the right parent class constructor
|
deba@989
|
826 |
explicit EdgeMap(const Graph&) {}
|
deba@1134
|
827 |
/// \brief Construct a new map with default value.
|
deba@1134
|
828 |
///
|
deba@1134
|
829 |
/// Construct a new map for the graph and initalise the values.
|
alpar@987
|
830 |
EdgeMap(const Graph&, const _Value&) {}
|
deba@1134
|
831 |
/// \brief Copy constructor.
|
deba@1134
|
832 |
///
|
deba@1134
|
833 |
/// Copy Constructor.
|
klao@959
|
834 |
EdgeMap(const EdgeMap&) {}
|
klao@959
|
835 |
|
deba@1134
|
836 |
/// \brief Assign operator.
|
deba@1134
|
837 |
///
|
deba@1134
|
838 |
/// Assign operator.
|
klao@959
|
839 |
EdgeMap& operator=(const EdgeMap&) { return *this;}
|
deba@989
|
840 |
|
klao@959
|
841 |
};
|
klao@959
|
842 |
|
deba@989
|
843 |
template <typename _Graph>
|
deba@989
|
844 |
struct Constraints {
|
klao@959
|
845 |
|
deba@989
|
846 |
struct Type {
|
deba@989
|
847 |
int value;
|
deba@989
|
848 |
Type() : value(0) {}
|
deba@989
|
849 |
Type(int _v) : value(_v) {}
|
deba@989
|
850 |
};
|
klao@959
|
851 |
|
deba@989
|
852 |
void constraints() {
|
deba@989
|
853 |
checkConcept<BaseGraphComponent, _Graph>();
|
deba@989
|
854 |
{ // int map test
|
deba@989
|
855 |
typedef typename _Graph::template NodeMap<int> IntNodeMap;
|
deba@1134
|
856 |
checkConcept<GraphMap<_Graph, typename _Graph::Node, int>,
|
deba@1134
|
857 |
IntNodeMap >();
|
deba@989
|
858 |
} { // bool map test
|
deba@989
|
859 |
typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
|
deba@1134
|
860 |
checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
|
deba@1134
|
861 |
BoolNodeMap >();
|
deba@989
|
862 |
} { // Type map test
|
deba@989
|
863 |
typedef typename _Graph::template NodeMap<Type> TypeNodeMap;
|
deba@1134
|
864 |
checkConcept<GraphMap<_Graph, typename _Graph::Node, Type>,
|
deba@1134
|
865 |
TypeNodeMap >();
|
deba@989
|
866 |
}
|
deba@989
|
867 |
|
deba@989
|
868 |
{ // int map test
|
deba@989
|
869 |
typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
|
deba@1134
|
870 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
|
deba@1134
|
871 |
IntEdgeMap >();
|
deba@989
|
872 |
} { // bool map test
|
deba@989
|
873 |
typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
|
deba@1134
|
874 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
|
deba@1134
|
875 |
BoolEdgeMap >();
|
deba@989
|
876 |
} { // Type map test
|
deba@989
|
877 |
typedef typename _Graph::template EdgeMap<Type> TypeEdgeMap;
|
deba@1134
|
878 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, Type>,
|
deba@1134
|
879 |
TypeEdgeMap >();
|
deba@989
|
880 |
}
|
deba@989
|
881 |
}
|
deba@989
|
882 |
|
deba@989
|
883 |
_Graph& graph;
|
klao@959
|
884 |
};
|
klao@959
|
885 |
};
|
klao@959
|
886 |
|
deba@1134
|
887 |
/// \brief An empty extendable extended graph class.
|
deba@1134
|
888 |
///
|
deba@1134
|
889 |
/// This class provides beside the core graph features
|
deba@1134
|
890 |
/// item addition interface for the graph structure.
|
deba@1134
|
891 |
/// The difference between this class and the
|
deba@1134
|
892 |
/// \c BaseExtendableGraphComponent is that it should
|
deba@1134
|
893 |
/// notify the item alteration observers.
|
klao@959
|
894 |
class ExtendableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
895 |
public:
|
klao@959
|
896 |
|
klao@959
|
897 |
typedef ExtendableGraphComponent Graph;
|
klao@959
|
898 |
|
klao@959
|
899 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
900 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
901 |
|
deba@1134
|
902 |
/// \brief Add a node to the graph.
|
deba@1134
|
903 |
///
|
deba@1134
|
904 |
/// Add a node to the graph and notify the observers.
|
klao@959
|
905 |
Node addNode() {
|
klao@959
|
906 |
return INVALID;
|
klao@959
|
907 |
}
|
klao@959
|
908 |
|
deba@1134
|
909 |
/// \brief Add an edge to the graph.
|
deba@1134
|
910 |
///
|
deba@1134
|
911 |
/// Add an edge to the graph and notify the observers.
|
klao@959
|
912 |
Edge addEdge(const Node& from, const Node& to) {
|
klao@959
|
913 |
return INVALID;
|
klao@959
|
914 |
}
|
klao@959
|
915 |
|
deba@989
|
916 |
template <typename _Graph>
|
deba@989
|
917 |
struct Constraints {
|
deba@989
|
918 |
void constraints() {
|
deba@989
|
919 |
checkConcept<BaseGraphComponent, _Graph >();
|
deba@989
|
920 |
typename _Graph::Node node_a, node_b;
|
deba@989
|
921 |
node_a = graph.addNode();
|
deba@989
|
922 |
typename _Graph::Edge edge;
|
deba@989
|
923 |
edge = graph.addEdge(node_a, node_b);
|
deba@989
|
924 |
}
|
deba@989
|
925 |
_Graph& graph;
|
deba@989
|
926 |
};
|
klao@959
|
927 |
};
|
deba@1134
|
928 |
|
deba@1134
|
929 |
/// \brief An empty erasable extended graph class.
|
deba@1134
|
930 |
///
|
deba@1134
|
931 |
/// This class provides beside the core graph features
|
deba@1134
|
932 |
/// item erase interface for the graph structure.
|
deba@1134
|
933 |
/// The difference between this class and the
|
deba@1134
|
934 |
/// \c BaseErasableGraphComponent is that it should
|
deba@1134
|
935 |
/// notify the item alteration observers.
|
klao@959
|
936 |
class ErasableGraphComponent : virtual public BaseGraphComponent {
|
klao@959
|
937 |
public:
|
klao@959
|
938 |
|
klao@959
|
939 |
typedef ErasableGraphComponent Graph;
|
klao@959
|
940 |
|
klao@959
|
941 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
942 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
943 |
|
deba@1134
|
944 |
/// \brief Erase the Node and notify the node alteration observers.
|
deba@1134
|
945 |
///
|
deba@1134
|
946 |
/// Erase the Node and notify the node alteration observers.
|
klao@959
|
947 |
void erase(const Node&) {}
|
deba@1134
|
948 |
|
deba@1134
|
949 |
/// \brief Erase the Edge and notify the edge alteration observers.
|
deba@1134
|
950 |
///
|
deba@1134
|
951 |
/// Erase the Edge and notify the edge alteration observers.
|
klao@959
|
952 |
void erase(const Edge&) {}
|
klao@959
|
953 |
|
deba@989
|
954 |
template <typename _Graph>
|
deba@989
|
955 |
struct Constraints {
|
deba@989
|
956 |
void constraints() {
|
deba@989
|
957 |
checkConcept<BaseGraphComponent, _Graph >();
|
deba@989
|
958 |
typename _Graph::Node node;
|
deba@989
|
959 |
graph.erase(node);
|
deba@989
|
960 |
typename _Graph::Edge edge;
|
deba@989
|
961 |
graph.erase(edge);
|
deba@989
|
962 |
}
|
klao@959
|
963 |
|
deba@989
|
964 |
_Graph& graph;
|
deba@989
|
965 |
};
|
klao@959
|
966 |
};
|
klao@959
|
967 |
|
klao@1030
|
968 |
/// @}
|
klao@1030
|
969 |
|
klao@959
|
970 |
}
|
klao@959
|
971 |
|
klao@959
|
972 |
}
|
klao@959
|
973 |
|
klao@959
|
974 |
#endif
|