alpar@906
|
1 |
/* -*- C++ -*-
|
alpar@921
|
2 |
* src/lemon/skeletons/graph.h - Part of LEMON, a generic C++ optimization library
|
alpar@906
|
3 |
*
|
alpar@906
|
4 |
* Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@906
|
5 |
* (Egervary Combinatorial Optimization Research Group, EGRES).
|
alpar@906
|
6 |
*
|
alpar@906
|
7 |
* Permission to use, modify and distribute this software is granted
|
alpar@906
|
8 |
* provided that this copyright notice appears in all copies. For
|
alpar@906
|
9 |
* precise terms see the accompanying LICENSE file.
|
alpar@906
|
10 |
*
|
alpar@906
|
11 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@906
|
12 |
* express or implied, and with no claim as to its suitability for any
|
alpar@906
|
13 |
* purpose.
|
alpar@906
|
14 |
*
|
alpar@906
|
15 |
*/
|
alpar@906
|
16 |
|
alpar@921
|
17 |
#ifndef LEMON_SKELETON_GRAPH_H
|
alpar@921
|
18 |
#define LEMON_SKELETON_GRAPH_H
|
alpar@52
|
19 |
|
alpar@794
|
20 |
///\ingroup skeletons
|
alpar@242
|
21 |
///\file
|
alpar@880
|
22 |
///\brief Declaration of Graph.
|
alpar@242
|
23 |
|
alpar@921
|
24 |
#include <lemon/invalid.h>
|
alpar@921
|
25 |
#include <lemon/skeletons/maps.h>
|
klao@946
|
26 |
#include <lemon/concept_check.h>
|
klao@946
|
27 |
#include <lemon/skeletons/graph_component.h>
|
alpar@145
|
28 |
|
alpar@921
|
29 |
namespace lemon {
|
alpar@732
|
30 |
namespace skeleton {
|
alpar@732
|
31 |
|
alpar@794
|
32 |
/// \addtogroup skeletons
|
alpar@794
|
33 |
/// @{
|
alpar@163
|
34 |
|
klao@946
|
35 |
// /// An empty static graph class.
|
alpar@732
|
36 |
|
klao@946
|
37 |
// /// This class provides all the common features of a graph structure,
|
klao@946
|
38 |
// /// however completely without implementations and real data structures
|
klao@946
|
39 |
// /// behind the interface.
|
klao@946
|
40 |
// /// All graph algorithms should compile with this class, but it will not
|
klao@946
|
41 |
// /// run properly, of course.
|
klao@946
|
42 |
// ///
|
klao@946
|
43 |
// /// It can be used for checking the interface compatibility,
|
klao@946
|
44 |
// /// or it can serve as a skeleton of a new graph structure.
|
klao@946
|
45 |
// ///
|
klao@946
|
46 |
// /// Also, you will find here the full documentation of a certain graph
|
klao@946
|
47 |
// /// feature, the documentation of a real graph imlementation
|
klao@946
|
48 |
// /// like @ref ListGraph or
|
klao@946
|
49 |
// /// @ref SmartGraph will just refer to this structure.
|
klao@946
|
50 |
// ///
|
klao@946
|
51 |
// /// \todo A pages describing the concept of concept description would
|
klao@946
|
52 |
// /// be nice.
|
klao@946
|
53 |
// class StaticGraph
|
klao@946
|
54 |
// {
|
klao@946
|
55 |
// public:
|
klao@946
|
56 |
// /// Defalult constructor.
|
klao@946
|
57 |
|
klao@946
|
58 |
// /// Defalult constructor.
|
klao@946
|
59 |
// ///
|
klao@946
|
60 |
// StaticGraph() { }
|
klao@946
|
61 |
// ///Copy consructor.
|
klao@946
|
62 |
|
klao@946
|
63 |
// // ///\todo It is not clear, what we expect from a copy constructor.
|
klao@946
|
64 |
// // ///E.g. How to assign the nodes/edges to each other? What about maps?
|
klao@946
|
65 |
// // StaticGraph(const StaticGraph& g) { }
|
klao@946
|
66 |
|
klao@946
|
67 |
// /// The base type of node iterators,
|
klao@946
|
68 |
// /// or in other words, the trivial node iterator.
|
klao@946
|
69 |
|
klao@946
|
70 |
// /// This is the base type of each node iterator,
|
klao@946
|
71 |
// /// thus each kind of node iterator converts to this.
|
klao@946
|
72 |
// /// More precisely each kind of node iterator should be inherited
|
klao@946
|
73 |
// /// from the trivial node iterator.
|
klao@946
|
74 |
// class Node {
|
klao@946
|
75 |
// public:
|
klao@946
|
76 |
// /// Default constructor
|
klao@946
|
77 |
|
klao@946
|
78 |
// /// @warning The default constructor sets the iterator
|
klao@946
|
79 |
// /// to an undefined value.
|
klao@946
|
80 |
// Node() { }
|
klao@946
|
81 |
// /// Copy constructor.
|
klao@946
|
82 |
|
klao@946
|
83 |
// /// Copy constructor.
|
klao@946
|
84 |
// ///
|
klao@946
|
85 |
// Node(const Node&) { }
|
klao@946
|
86 |
|
klao@946
|
87 |
// /// Invalid constructor \& conversion.
|
klao@946
|
88 |
|
klao@946
|
89 |
// /// This constructor initializes the iterator to be invalid.
|
klao@946
|
90 |
// /// \sa Invalid for more details.
|
klao@946
|
91 |
// Node(Invalid) { }
|
klao@946
|
92 |
// /// Equality operator
|
klao@946
|
93 |
|
klao@946
|
94 |
// /// Two iterators are equal if and only if they point to the
|
klao@946
|
95 |
// /// same object or both are invalid.
|
klao@946
|
96 |
// bool operator==(Node) const { return true; }
|
klao@946
|
97 |
|
klao@946
|
98 |
// /// Inequality operator
|
klao@946
|
99 |
|
klao@946
|
100 |
// /// \sa operator==(Node n)
|
klao@946
|
101 |
// ///
|
klao@946
|
102 |
// bool operator!=(Node) const { return true; }
|
klao@946
|
103 |
|
klao@946
|
104 |
// ///Comparison operator.
|
klao@946
|
105 |
|
klao@946
|
106 |
// ///This is a strict ordering between the nodes.
|
klao@946
|
107 |
// ///
|
klao@946
|
108 |
// ///This ordering can be different from the order in which NodeIt
|
klao@946
|
109 |
// ///goes through the nodes.
|
klao@946
|
110 |
// ///\todo Possibly we don't need it.
|
klao@946
|
111 |
// bool operator<(Node) const { return true; }
|
klao@946
|
112 |
// };
|
klao@946
|
113 |
|
klao@946
|
114 |
// /// This iterator goes through each node.
|
klao@946
|
115 |
|
klao@946
|
116 |
// /// This iterator goes through each node.
|
klao@946
|
117 |
// /// Its usage is quite simple, for example you can count the number
|
klao@946
|
118 |
// /// of nodes in graph \c g of type \c Graph like this:
|
klao@946
|
119 |
// /// \code
|
klao@946
|
120 |
// /// int count=0;
|
klao@946
|
121 |
// /// for (Graph::NodeIt n(g); n!=INVALID ++n) ++count;
|
klao@946
|
122 |
// /// \endcode
|
klao@946
|
123 |
// class NodeIt : public Node {
|
klao@946
|
124 |
// public:
|
klao@946
|
125 |
// /// Default constructor
|
klao@946
|
126 |
|
klao@946
|
127 |
// /// @warning The default constructor sets the iterator
|
klao@946
|
128 |
// /// to an undefined value.
|
klao@946
|
129 |
// NodeIt() { }
|
klao@946
|
130 |
// /// Copy constructor.
|
klao@946
|
131 |
|
klao@946
|
132 |
// /// Copy constructor.
|
klao@946
|
133 |
// ///
|
klao@946
|
134 |
// NodeIt(const NodeIt&) { }
|
klao@946
|
135 |
// /// Invalid constructor \& conversion.
|
klao@946
|
136 |
|
klao@946
|
137 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
138 |
// /// \sa Invalid for more details.
|
klao@946
|
139 |
// NodeIt(Invalid) { }
|
klao@946
|
140 |
// /// Sets the iterator to the first node.
|
klao@946
|
141 |
|
klao@946
|
142 |
// /// Sets the iterator to the first node of \c g.
|
klao@946
|
143 |
// ///
|
klao@946
|
144 |
// NodeIt(const StaticGraph& g) { }
|
klao@946
|
145 |
// /// Node -> NodeIt conversion.
|
klao@946
|
146 |
|
klao@946
|
147 |
// /// Sets the iterator to the node of \c g pointed by the trivial
|
klao@946
|
148 |
// /// iterator n.
|
klao@946
|
149 |
// /// This feature necessitates that each time we
|
klao@946
|
150 |
// /// iterate the edge-set, the iteration order is the same.
|
klao@946
|
151 |
// NodeIt(const StaticGraph& g, const Node& n) { }
|
klao@946
|
152 |
// /// Next node.
|
klao@946
|
153 |
|
klao@946
|
154 |
// /// Assign the iterator to the next node.
|
klao@946
|
155 |
// ///
|
klao@946
|
156 |
// NodeIt& operator++() { return *this; }
|
klao@946
|
157 |
// };
|
klao@946
|
158 |
|
klao@946
|
159 |
|
klao@946
|
160 |
// /// The base type of the edge iterators.
|
klao@946
|
161 |
|
klao@946
|
162 |
// /// The base type of the edge iterators.
|
klao@946
|
163 |
// ///
|
klao@946
|
164 |
// class Edge {
|
klao@946
|
165 |
// public:
|
klao@946
|
166 |
// /// Default constructor
|
klao@946
|
167 |
|
klao@946
|
168 |
// /// @warning The default constructor sets the iterator
|
klao@946
|
169 |
// /// to an undefined value.
|
klao@946
|
170 |
// Edge() { }
|
klao@946
|
171 |
// /// Copy constructor.
|
klao@946
|
172 |
|
klao@946
|
173 |
// /// Copy constructor.
|
klao@946
|
174 |
// ///
|
klao@946
|
175 |
// Edge(const Edge&) { }
|
klao@946
|
176 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
177 |
|
klao@946
|
178 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
179 |
// ///
|
klao@946
|
180 |
// Edge(Invalid) { }
|
klao@946
|
181 |
// /// Equality operator
|
klao@946
|
182 |
|
klao@946
|
183 |
// /// Two iterators are equal if and only if they point to the
|
klao@946
|
184 |
// /// same object or both are invalid.
|
klao@946
|
185 |
// bool operator==(Edge) const { return true; }
|
klao@946
|
186 |
// /// Inequality operator
|
klao@946
|
187 |
|
klao@946
|
188 |
// /// \sa operator==(Node n)
|
klao@946
|
189 |
// ///
|
klao@946
|
190 |
// bool operator!=(Edge) const { return true; }
|
klao@946
|
191 |
// ///Comparison operator.
|
klao@946
|
192 |
|
klao@946
|
193 |
// ///This is a strict ordering between the nodes.
|
klao@946
|
194 |
// ///
|
klao@946
|
195 |
// ///This ordering can be different from the order in which NodeIt
|
klao@946
|
196 |
// ///goes through the nodes.
|
klao@946
|
197 |
// ///\todo Possibly we don't need it.
|
klao@946
|
198 |
// bool operator<(Edge) const { return true; }
|
klao@946
|
199 |
// };
|
klao@946
|
200 |
|
klao@946
|
201 |
// /// This iterator goes trough the outgoing edges of a node.
|
klao@946
|
202 |
|
klao@946
|
203 |
// /// This iterator goes trough the \e outgoing edges of a certain node
|
klao@946
|
204 |
// /// of a graph.
|
klao@946
|
205 |
// /// Its usage is quite simple, for example you can count the number
|
klao@946
|
206 |
// /// of outgoing edges of a node \c n
|
klao@946
|
207 |
// /// in graph \c g of type \c Graph as follows.
|
klao@946
|
208 |
// /// \code
|
klao@946
|
209 |
// /// int count=0;
|
klao@946
|
210 |
// /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
klao@946
|
211 |
// /// \endcode
|
klao@946
|
212 |
|
klao@946
|
213 |
// class OutEdgeIt : public Edge {
|
klao@946
|
214 |
// public:
|
klao@946
|
215 |
// /// Default constructor
|
klao@946
|
216 |
|
klao@946
|
217 |
// /// @warning The default constructor sets the iterator
|
klao@946
|
218 |
// /// to an undefined value.
|
klao@946
|
219 |
// OutEdgeIt() { }
|
klao@946
|
220 |
// /// Copy constructor.
|
klao@946
|
221 |
|
klao@946
|
222 |
// /// Copy constructor.
|
klao@946
|
223 |
// ///
|
klao@946
|
224 |
// OutEdgeIt(const OutEdgeIt&) { }
|
klao@946
|
225 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
226 |
|
klao@946
|
227 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
228 |
// ///
|
klao@946
|
229 |
// OutEdgeIt(Invalid) { }
|
klao@946
|
230 |
// /// This constructor sets the iterator to first outgoing edge.
|
klao@946
|
231 |
|
klao@946
|
232 |
// /// This constructor set the iterator to the first outgoing edge of
|
klao@946
|
233 |
// /// node
|
klao@946
|
234 |
// ///@param n the node
|
klao@946
|
235 |
// ///@param g the graph
|
klao@946
|
236 |
// OutEdgeIt(const StaticGraph& g, const Node& n) { }
|
klao@946
|
237 |
// /// Edge -> OutEdgeIt conversion
|
klao@946
|
238 |
|
klao@946
|
239 |
// /// Sets the iterator to the value of the trivial iterator \c e.
|
klao@946
|
240 |
// /// This feature necessitates that each time we
|
klao@946
|
241 |
// /// iterate the edge-set, the iteration order is the same.
|
klao@946
|
242 |
// OutEdgeIt(const StaticGraph& g, const Edge& e) { }
|
klao@946
|
243 |
// ///Next outgoing edge
|
klao@946
|
244 |
|
klao@946
|
245 |
// /// Assign the iterator to the next
|
klao@946
|
246 |
// /// outgoing edge of the corresponding node.
|
klao@946
|
247 |
// OutEdgeIt& operator++() { return *this; }
|
klao@946
|
248 |
// };
|
klao@946
|
249 |
|
klao@946
|
250 |
// /// This iterator goes trough the incoming edges of a node.
|
klao@946
|
251 |
|
klao@946
|
252 |
// /// This iterator goes trough the \e incoming edges of a certain node
|
klao@946
|
253 |
// /// of a graph.
|
klao@946
|
254 |
// /// Its usage is quite simple, for example you can count the number
|
klao@946
|
255 |
// /// of outgoing edges of a node \c n
|
klao@946
|
256 |
// /// in graph \c g of type \c Graph as follows.
|
klao@946
|
257 |
// /// \code
|
klao@946
|
258 |
// /// int count=0;
|
klao@946
|
259 |
// /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
klao@946
|
260 |
// /// \endcode
|
klao@946
|
261 |
|
klao@946
|
262 |
// class InEdgeIt : public Edge {
|
klao@946
|
263 |
// public:
|
klao@946
|
264 |
// /// Default constructor
|
klao@946
|
265 |
|
klao@946
|
266 |
// /// @warning The default constructor sets the iterator
|
klao@946
|
267 |
// /// to an undefined value.
|
klao@946
|
268 |
// InEdgeIt() { }
|
klao@946
|
269 |
// /// Copy constructor.
|
klao@946
|
270 |
|
klao@946
|
271 |
// /// Copy constructor.
|
klao@946
|
272 |
// ///
|
klao@946
|
273 |
// InEdgeIt(const InEdgeIt&) { }
|
klao@946
|
274 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
275 |
|
klao@946
|
276 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
277 |
// ///
|
klao@946
|
278 |
// InEdgeIt(Invalid) { }
|
klao@946
|
279 |
// /// This constructor sets the iterator to first incoming edge.
|
klao@946
|
280 |
|
klao@946
|
281 |
// /// This constructor set the iterator to the first incoming edge of
|
klao@946
|
282 |
// /// node
|
klao@946
|
283 |
// ///@param n the node
|
klao@946
|
284 |
// ///@param g the graph
|
klao@946
|
285 |
// InEdgeIt(const StaticGraph& g, const Node& n) { }
|
klao@946
|
286 |
// /// Edge -> InEdgeIt conversion
|
klao@946
|
287 |
|
klao@946
|
288 |
// /// Sets the iterator to the value of the trivial iterator \c e.
|
klao@946
|
289 |
// /// This feature necessitates that each time we
|
klao@946
|
290 |
// /// iterate the edge-set, the iteration order is the same.
|
klao@946
|
291 |
// InEdgeIt(const StaticGraph& g, const Edge& n) { }
|
klao@946
|
292 |
// /// Next incoming edge
|
klao@946
|
293 |
|
klao@946
|
294 |
// /// Assign the iterator to the next inedge of the corresponding node.
|
klao@946
|
295 |
// ///
|
klao@946
|
296 |
// InEdgeIt& operator++() { return *this; }
|
klao@946
|
297 |
// };
|
klao@946
|
298 |
// /// This iterator goes through each edge.
|
klao@946
|
299 |
|
klao@946
|
300 |
// /// This iterator goes through each edge of a graph.
|
klao@946
|
301 |
// /// Its usage is quite simple, for example you can count the number
|
klao@946
|
302 |
// /// of edges in a graph \c g of type \c Graph as follows:
|
klao@946
|
303 |
// /// \code
|
klao@946
|
304 |
// /// int count=0;
|
klao@946
|
305 |
// /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
|
klao@946
|
306 |
// /// \endcode
|
klao@946
|
307 |
// class EdgeIt : public Edge {
|
klao@946
|
308 |
// public:
|
klao@946
|
309 |
// /// Default constructor
|
klao@946
|
310 |
|
klao@946
|
311 |
// /// @warning The default constructor sets the iterator
|
klao@946
|
312 |
// /// to an undefined value.
|
klao@946
|
313 |
// EdgeIt() { }
|
klao@946
|
314 |
// /// Copy constructor.
|
klao@946
|
315 |
|
klao@946
|
316 |
// /// Copy constructor.
|
klao@946
|
317 |
// ///
|
klao@946
|
318 |
// EdgeIt(const EdgeIt&) { }
|
klao@946
|
319 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
320 |
|
klao@946
|
321 |
// /// Initialize the iterator to be invalid.
|
klao@946
|
322 |
// ///
|
klao@946
|
323 |
// EdgeIt(Invalid) { }
|
klao@946
|
324 |
// /// This constructor sets the iterator to first edge.
|
klao@946
|
325 |
|
klao@946
|
326 |
// /// This constructor set the iterator to the first edge of
|
klao@946
|
327 |
// /// node
|
klao@946
|
328 |
// ///@param g the graph
|
klao@946
|
329 |
// EdgeIt(const StaticGraph& g) { }
|
klao@946
|
330 |
// /// Edge -> EdgeIt conversion
|
klao@946
|
331 |
|
klao@946
|
332 |
// /// Sets the iterator to the value of the trivial iterator \c e.
|
klao@946
|
333 |
// /// This feature necessitates that each time we
|
klao@946
|
334 |
// /// iterate the edge-set, the iteration order is the same.
|
klao@946
|
335 |
// EdgeIt(const StaticGraph&, const Edge&) { }
|
klao@946
|
336 |
// ///Next edge
|
klao@946
|
337 |
|
klao@946
|
338 |
// /// Assign the iterator to the next
|
klao@946
|
339 |
// /// edge of the corresponding node.
|
klao@946
|
340 |
// EdgeIt& operator++() { return *this; }
|
klao@946
|
341 |
// };
|
klao@946
|
342 |
|
klao@946
|
343 |
// /// First node of the graph.
|
klao@946
|
344 |
|
klao@946
|
345 |
// /// \retval i the first node.
|
klao@946
|
346 |
// /// \return the first node.
|
klao@946
|
347 |
// ///
|
klao@946
|
348 |
// NodeIt& first(NodeIt& i) const { return i; }
|
klao@946
|
349 |
|
klao@946
|
350 |
// /// The first incoming edge.
|
klao@946
|
351 |
|
klao@946
|
352 |
// /// The first incoming edge.
|
klao@946
|
353 |
// ///
|
klao@946
|
354 |
// InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
|
klao@946
|
355 |
// /// The first outgoing edge.
|
klao@946
|
356 |
|
klao@946
|
357 |
// /// The first outgoing edge.
|
klao@946
|
358 |
// ///
|
klao@946
|
359 |
// OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
|
klao@946
|
360 |
// /// The first edge of the Graph.
|
klao@946
|
361 |
|
klao@946
|
362 |
// /// The first edge of the Graph.
|
klao@946
|
363 |
// ///
|
klao@946
|
364 |
// EdgeIt& first(EdgeIt& i) const { return i; }
|
klao@946
|
365 |
|
klao@946
|
366 |
// ///Gives back the head node of an edge.
|
klao@946
|
367 |
|
klao@946
|
368 |
// ///Gives back the head node of an edge.
|
klao@946
|
369 |
// ///
|
klao@946
|
370 |
// Node head(Edge) const { return INVALID; }
|
klao@946
|
371 |
// ///Gives back the tail node of an edge.
|
klao@946
|
372 |
|
klao@946
|
373 |
// ///Gives back the tail node of an edge.
|
klao@946
|
374 |
// ///
|
klao@946
|
375 |
// Node tail(Edge) const { return INVALID; }
|
klao@946
|
376 |
|
klao@946
|
377 |
// ///Gives back the \e id of a node.
|
klao@946
|
378 |
|
klao@946
|
379 |
// ///\warning Not all graph structures provide this feature.
|
klao@946
|
380 |
// ///
|
klao@946
|
381 |
// ///\todo Should each graph provide \c id?
|
klao@946
|
382 |
// int id(const Node&) const { return 0; }
|
klao@946
|
383 |
// ///Gives back the \e id of an edge.
|
klao@946
|
384 |
|
klao@946
|
385 |
// ///\warning Not all graph structures provide this feature.
|
klao@946
|
386 |
// ///
|
klao@946
|
387 |
// ///\todo Should each graph provide \c id?
|
klao@946
|
388 |
// int id(const Edge&) const { return 0; }
|
klao@946
|
389 |
|
klao@946
|
390 |
// ///\e
|
klao@946
|
391 |
|
klao@946
|
392 |
// ///\todo Should it be in the concept?
|
klao@946
|
393 |
// ///
|
klao@946
|
394 |
// int nodeNum() const { return 0; }
|
klao@946
|
395 |
// ///\e
|
klao@946
|
396 |
|
klao@946
|
397 |
// ///\todo Should it be in the concept?
|
klao@946
|
398 |
// ///
|
klao@946
|
399 |
// int edgeNum() const { return 0; }
|
klao@946
|
400 |
|
klao@946
|
401 |
|
klao@946
|
402 |
// ///Reference map of the nodes to type \c T.
|
klao@946
|
403 |
|
klao@946
|
404 |
// /// \ingroup skeletons
|
klao@946
|
405 |
// ///Reference map of the nodes to type \c T.
|
klao@946
|
406 |
// /// \sa Reference
|
klao@946
|
407 |
// /// \warning Making maps that can handle bool type (NodeMap<bool>)
|
klao@946
|
408 |
// /// needs some extra attention!
|
klao@946
|
409 |
// template<class T> class NodeMap : public ReferenceMap< Node, T >
|
klao@946
|
410 |
// {
|
klao@946
|
411 |
// public:
|
klao@946
|
412 |
|
klao@946
|
413 |
// ///\e
|
klao@946
|
414 |
// NodeMap(const StaticGraph&) { }
|
klao@946
|
415 |
// ///\e
|
klao@946
|
416 |
// NodeMap(const StaticGraph&, T) { }
|
klao@946
|
417 |
|
klao@946
|
418 |
// ///Copy constructor
|
klao@946
|
419 |
// template<typename TT> NodeMap(const NodeMap<TT>&) { }
|
klao@946
|
420 |
// ///Assignment operator
|
klao@946
|
421 |
// template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
|
klao@946
|
422 |
// { return *this; }
|
klao@946
|
423 |
// };
|
klao@946
|
424 |
|
klao@946
|
425 |
// ///Reference map of the edges to type \c T.
|
klao@946
|
426 |
|
klao@946
|
427 |
// /// \ingroup skeletons
|
klao@946
|
428 |
// ///Reference map of the edges to type \c T.
|
klao@946
|
429 |
// /// \sa Reference
|
klao@946
|
430 |
// /// \warning Making maps that can handle bool type (EdgeMap<bool>)
|
klao@946
|
431 |
// /// needs some extra attention!
|
klao@946
|
432 |
// template<class T> class EdgeMap
|
klao@946
|
433 |
// : public ReferenceMap<Edge,T>
|
klao@946
|
434 |
// {
|
klao@946
|
435 |
// public:
|
klao@946
|
436 |
|
klao@946
|
437 |
// ///\e
|
klao@946
|
438 |
// EdgeMap(const StaticGraph&) { }
|
klao@946
|
439 |
// ///\e
|
klao@946
|
440 |
// EdgeMap(const StaticGraph&, T) { }
|
klao@946
|
441 |
|
klao@946
|
442 |
// ///Copy constructor
|
klao@946
|
443 |
// template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
|
klao@946
|
444 |
// ///Assignment operator
|
klao@946
|
445 |
// template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
|
klao@946
|
446 |
// { return *this; }
|
klao@946
|
447 |
// };
|
klao@946
|
448 |
// };
|
klao@946
|
449 |
|
klao@946
|
450 |
// struct DummyType {
|
klao@946
|
451 |
// int value;
|
klao@946
|
452 |
// DummyType() {}
|
klao@946
|
453 |
// DummyType(int p) : value(p) {}
|
klao@946
|
454 |
// DummyType& operator=(int p) { value = p; return *this;}
|
klao@946
|
455 |
// };
|
klao@946
|
456 |
|
klao@946
|
457 |
// ///\brief Checks whether \c G meets the
|
klao@946
|
458 |
// ///\ref lemon::skeleton::StaticGraph "StaticGraph" concept
|
klao@946
|
459 |
// template<class Graph> void checkCompileStaticGraph(Graph &G)
|
klao@946
|
460 |
// {
|
klao@946
|
461 |
// typedef typename Graph::Node Node;
|
klao@946
|
462 |
// typedef typename Graph::NodeIt NodeIt;
|
klao@946
|
463 |
// typedef typename Graph::Edge Edge;
|
klao@946
|
464 |
// typedef typename Graph::EdgeIt EdgeIt;
|
klao@946
|
465 |
// typedef typename Graph::InEdgeIt InEdgeIt;
|
klao@946
|
466 |
// typedef typename Graph::OutEdgeIt OutEdgeIt;
|
klao@946
|
467 |
|
klao@946
|
468 |
// {
|
klao@946
|
469 |
// Node i; Node j(i); Node k(INVALID);
|
klao@946
|
470 |
// i=j;
|
klao@946
|
471 |
// bool b; b=true;
|
klao@946
|
472 |
// b=(i==INVALID); b=(i!=INVALID);
|
klao@946
|
473 |
// b=(i==j); b=(i!=j); b=(i<j);
|
klao@946
|
474 |
// }
|
klao@946
|
475 |
// {
|
klao@946
|
476 |
// NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
|
klao@946
|
477 |
// i=j;
|
klao@946
|
478 |
// j=G.first(i);
|
klao@946
|
479 |
// j=++i;
|
klao@946
|
480 |
// bool b; b=true;
|
klao@946
|
481 |
// b=(i==INVALID); b=(i!=INVALID);
|
klao@946
|
482 |
// Node n(i);
|
klao@946
|
483 |
// n=i;
|
klao@946
|
484 |
// b=(i==j); b=(i!=j); b=(i<j);
|
klao@946
|
485 |
// //Node ->NodeIt conversion
|
klao@946
|
486 |
// NodeIt ni(G,n);
|
klao@946
|
487 |
// }
|
klao@946
|
488 |
// {
|
klao@946
|
489 |
// Edge i; Edge j(i); Edge k(INVALID);
|
klao@946
|
490 |
// i=j;
|
klao@946
|
491 |
// bool b; b=true;
|
klao@946
|
492 |
// b=(i==INVALID); b=(i!=INVALID);
|
klao@946
|
493 |
// b=(i==j); b=(i!=j); b=(i<j);
|
klao@946
|
494 |
// }
|
klao@946
|
495 |
// {
|
klao@946
|
496 |
// EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
|
klao@946
|
497 |
// i=j;
|
klao@946
|
498 |
// j=G.first(i);
|
klao@946
|
499 |
// j=++i;
|
klao@946
|
500 |
// bool b; b=true;
|
klao@946
|
501 |
// b=(i==INVALID); b=(i!=INVALID);
|
klao@946
|
502 |
// Edge e(i);
|
klao@946
|
503 |
// e=i;
|
klao@946
|
504 |
// b=(i==j); b=(i!=j); b=(i<j);
|
klao@946
|
505 |
// //Edge ->EdgeIt conversion
|
klao@946
|
506 |
// EdgeIt ei(G,e);
|
klao@946
|
507 |
// }
|
klao@946
|
508 |
// {
|
klao@946
|
509 |
// Node n;
|
klao@946
|
510 |
// InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
|
klao@946
|
511 |
// i=j;
|
klao@946
|
512 |
// j=G.first(i,n);
|
klao@946
|
513 |
// j=++i;
|
klao@946
|
514 |
// bool b; b=true;
|
klao@946
|
515 |
// b=(i==INVALID); b=(i!=INVALID);
|
klao@946
|
516 |
// Edge e(i);
|
klao@946
|
517 |
// e=i;
|
klao@946
|
518 |
// b=(i==j); b=(i!=j); b=(i<j);
|
klao@946
|
519 |
// //Edge ->InEdgeIt conversion
|
klao@946
|
520 |
// InEdgeIt ei(G,e);
|
klao@946
|
521 |
// }
|
klao@946
|
522 |
// {
|
klao@946
|
523 |
// Node n;
|
klao@946
|
524 |
// OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
|
klao@946
|
525 |
// i=j;
|
klao@946
|
526 |
// j=G.first(i,n);
|
klao@946
|
527 |
// j=++i;
|
klao@946
|
528 |
// bool b; b=true;
|
klao@946
|
529 |
// b=(i==INVALID); b=(i!=INVALID);
|
klao@946
|
530 |
// Edge e(i);
|
klao@946
|
531 |
// e=i;
|
klao@946
|
532 |
// b=(i==j); b=(i!=j); b=(i<j);
|
klao@946
|
533 |
// //Edge ->OutEdgeIt conversion
|
klao@946
|
534 |
// OutEdgeIt ei(G,e);
|
klao@946
|
535 |
// }
|
klao@946
|
536 |
// {
|
klao@946
|
537 |
// Node n,m;
|
klao@946
|
538 |
// n=m=INVALID;
|
klao@946
|
539 |
// Edge e;
|
klao@946
|
540 |
// e=INVALID;
|
klao@946
|
541 |
// n=G.tail(e);
|
klao@946
|
542 |
// n=G.head(e);
|
klao@946
|
543 |
// }
|
klao@946
|
544 |
// // id tests
|
klao@946
|
545 |
// { Node n; int i=G.id(n); i=i; }
|
klao@946
|
546 |
// { Edge e; int i=G.id(e); i=i; }
|
klao@946
|
547 |
// //NodeMap tests
|
klao@946
|
548 |
// {
|
klao@946
|
549 |
// Node k;
|
klao@946
|
550 |
// typename Graph::template NodeMap<int> m(G);
|
klao@946
|
551 |
// //Const map
|
klao@946
|
552 |
// typename Graph::template NodeMap<int> const &cm = m;
|
klao@946
|
553 |
// //Inicialize with default value
|
klao@946
|
554 |
// typename Graph::template NodeMap<int> mdef(G,12);
|
klao@946
|
555 |
// //Copy
|
klao@946
|
556 |
// typename Graph::template NodeMap<int> mm(cm);
|
klao@946
|
557 |
// //Copy from another type
|
klao@946
|
558 |
// typename Graph::template NodeMap<double> dm(cm);
|
klao@946
|
559 |
// //Copy to more complex type
|
klao@946
|
560 |
// typename Graph::template NodeMap<DummyType> em(cm);
|
klao@946
|
561 |
// int v;
|
klao@946
|
562 |
// v=m[k]; m[k]=v; m.set(k,v);
|
klao@946
|
563 |
// v=cm[k];
|
klao@946
|
564 |
|
klao@946
|
565 |
// m=cm;
|
klao@946
|
566 |
// dm=cm; //Copy from another type
|
klao@946
|
567 |
// em=cm; //Copy to more complex type
|
klao@946
|
568 |
// {
|
klao@946
|
569 |
// //Check the typedef's
|
klao@946
|
570 |
// typename Graph::template NodeMap<int>::ValueType val;
|
klao@946
|
571 |
// val=1;
|
klao@946
|
572 |
// typename Graph::template NodeMap<int>::KeyType key;
|
klao@946
|
573 |
// key = typename Graph::NodeIt(G);
|
klao@946
|
574 |
// }
|
klao@946
|
575 |
// }
|
klao@946
|
576 |
// { //bool NodeMap
|
klao@946
|
577 |
// Node k;
|
klao@946
|
578 |
// typename Graph::template NodeMap<bool> m(G);
|
klao@946
|
579 |
// typename Graph::template NodeMap<bool> const &cm = m; //Const map
|
klao@946
|
580 |
// //Inicialize with default value
|
klao@946
|
581 |
// typename Graph::template NodeMap<bool> mdef(G,12);
|
klao@946
|
582 |
// typename Graph::template NodeMap<bool> mm(cm); //Copy
|
klao@946
|
583 |
// typename Graph::template NodeMap<int> dm(cm); //Copy from another type
|
klao@946
|
584 |
// bool v;
|
klao@946
|
585 |
// v=m[k]; m[k]=v; m.set(k,v);
|
klao@946
|
586 |
// v=cm[k];
|
klao@946
|
587 |
|
klao@946
|
588 |
// m=cm;
|
klao@946
|
589 |
// dm=cm; //Copy from another type
|
klao@946
|
590 |
// m=dm; //Copy to another type
|
klao@946
|
591 |
|
klao@946
|
592 |
// {
|
klao@946
|
593 |
// //Check the typedef's
|
klao@946
|
594 |
// typename Graph::template NodeMap<bool>::ValueType val;
|
klao@946
|
595 |
// val=true;
|
klao@946
|
596 |
// typename Graph::template NodeMap<bool>::KeyType key;
|
klao@946
|
597 |
// key= typename Graph::NodeIt(G);
|
klao@946
|
598 |
// }
|
klao@946
|
599 |
// }
|
klao@946
|
600 |
// //EdgeMap tests
|
klao@946
|
601 |
// {
|
klao@946
|
602 |
// Edge k;
|
klao@946
|
603 |
// typename Graph::template EdgeMap<int> m(G);
|
klao@946
|
604 |
// typename Graph::template EdgeMap<int> const &cm = m; //Const map
|
klao@946
|
605 |
// //Inicialize with default value
|
klao@946
|
606 |
// typename Graph::template EdgeMap<int> mdef(G,12);
|
klao@946
|
607 |
// typename Graph::template EdgeMap<int> mm(cm); //Copy
|
klao@946
|
608 |
// typename Graph::template EdgeMap<double> dm(cm);//Copy from another type
|
klao@946
|
609 |
// int v;
|
klao@946
|
610 |
// v=m[k]; m[k]=v; m.set(k,v);
|
klao@946
|
611 |
// v=cm[k];
|
klao@946
|
612 |
|
klao@946
|
613 |
// m=cm;
|
klao@946
|
614 |
// dm=cm; //Copy from another type
|
klao@946
|
615 |
// {
|
klao@946
|
616 |
// //Check the typedef's
|
klao@946
|
617 |
// typename Graph::template EdgeMap<int>::ValueType val;
|
klao@946
|
618 |
// val=1;
|
klao@946
|
619 |
// typename Graph::template EdgeMap<int>::KeyType key;
|
klao@946
|
620 |
// key= typename Graph::EdgeIt(G);
|
klao@946
|
621 |
// }
|
klao@946
|
622 |
// }
|
klao@946
|
623 |
// { //bool EdgeMap
|
klao@946
|
624 |
// Edge k;
|
klao@946
|
625 |
// typename Graph::template EdgeMap<bool> m(G);
|
klao@946
|
626 |
// typename Graph::template EdgeMap<bool> const &cm = m; //Const map
|
klao@946
|
627 |
// //Inicialize with default value
|
klao@946
|
628 |
// typename Graph::template EdgeMap<bool> mdef(G,12);
|
klao@946
|
629 |
// typename Graph::template EdgeMap<bool> mm(cm); //Copy
|
klao@946
|
630 |
// typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
|
klao@946
|
631 |
// bool v;
|
klao@946
|
632 |
// v=m[k]; m[k]=v; m.set(k,v);
|
klao@946
|
633 |
// v=cm[k];
|
klao@946
|
634 |
|
klao@946
|
635 |
// m=cm;
|
klao@946
|
636 |
// dm=cm; //Copy from another type
|
klao@946
|
637 |
// m=dm; //Copy to another type
|
klao@946
|
638 |
// {
|
klao@946
|
639 |
// //Check the typedef's
|
klao@946
|
640 |
// typename Graph::template EdgeMap<bool>::ValueType val;
|
klao@946
|
641 |
// val=true;
|
klao@946
|
642 |
// typename Graph::template EdgeMap<bool>::KeyType key;
|
klao@946
|
643 |
// key= typename Graph::EdgeIt(G);
|
klao@946
|
644 |
// }
|
klao@946
|
645 |
// }
|
klao@946
|
646 |
// }
|
klao@946
|
647 |
|
klao@946
|
648 |
// /// An empty non-static graph class.
|
klao@946
|
649 |
|
klao@946
|
650 |
// /// This class provides everything that \ref StaticGraph
|
klao@946
|
651 |
// /// with additional functionality which enables to build a
|
klao@946
|
652 |
// /// graph from scratch.
|
klao@946
|
653 |
// class ExtendableGraph : public StaticGraph
|
klao@946
|
654 |
// {
|
klao@946
|
655 |
// public:
|
klao@946
|
656 |
// /// Defalult constructor.
|
klao@946
|
657 |
|
klao@946
|
658 |
// /// Defalult constructor.
|
klao@946
|
659 |
// ///
|
klao@946
|
660 |
// ExtendableGraph() { }
|
klao@946
|
661 |
// ///Add a new node to the graph.
|
klao@946
|
662 |
|
klao@946
|
663 |
// /// \return the new node.
|
klao@946
|
664 |
// ///
|
klao@946
|
665 |
// Node addNode() { return INVALID; }
|
klao@946
|
666 |
// ///Add a new edge to the graph.
|
klao@946
|
667 |
|
klao@946
|
668 |
// ///Add a new edge to the graph with tail node \c t
|
klao@946
|
669 |
// ///and head node \c h.
|
klao@946
|
670 |
// ///\return the new edge.
|
klao@946
|
671 |
// Edge addEdge(Node h, Node t) { return INVALID; }
|
klao@946
|
672 |
|
klao@946
|
673 |
// /// Resets the graph.
|
klao@946
|
674 |
|
klao@946
|
675 |
// /// This function deletes all edges and nodes of the graph.
|
klao@946
|
676 |
// /// It also frees the memory allocated to store them.
|
klao@946
|
677 |
// /// \todo It might belong to \ref ErasableGraph.
|
klao@946
|
678 |
// void clear() { }
|
klao@946
|
679 |
// };
|
klao@946
|
680 |
|
klao@946
|
681 |
|
klao@946
|
682 |
// ///\brief Checks whether \c G meets the
|
klao@946
|
683 |
// ///\ref lemon::skeleton::ExtendableGraph "ExtendableGraph" concept
|
klao@946
|
684 |
// template<class Graph> void checkCompileExtendableGraph(Graph &G)
|
klao@946
|
685 |
// {
|
klao@946
|
686 |
// checkCompileStaticGraph(G);
|
klao@946
|
687 |
|
klao@946
|
688 |
// typedef typename Graph::Node Node;
|
klao@946
|
689 |
// typedef typename Graph::NodeIt NodeIt;
|
klao@946
|
690 |
// typedef typename Graph::Edge Edge;
|
klao@946
|
691 |
// typedef typename Graph::EdgeIt EdgeIt;
|
klao@946
|
692 |
// typedef typename Graph::InEdgeIt InEdgeIt;
|
klao@946
|
693 |
// typedef typename Graph::OutEdgeIt OutEdgeIt;
|
klao@946
|
694 |
|
klao@946
|
695 |
// Node n,m;
|
klao@946
|
696 |
// n=G.addNode();
|
klao@946
|
697 |
// m=G.addNode();
|
klao@946
|
698 |
// Edge e;
|
klao@946
|
699 |
// e=G.addEdge(n,m);
|
klao@946
|
700 |
|
klao@946
|
701 |
// // G.clear();
|
klao@946
|
702 |
// }
|
klao@946
|
703 |
|
klao@946
|
704 |
|
klao@946
|
705 |
// /// An empty erasable graph class.
|
klao@946
|
706 |
|
klao@946
|
707 |
// /// This class is an extension of \ref ExtendableGraph. It also makes it
|
klao@946
|
708 |
// /// possible to erase edges or nodes.
|
klao@946
|
709 |
// class ErasableGraph : public ExtendableGraph
|
klao@946
|
710 |
// {
|
klao@946
|
711 |
// public:
|
klao@946
|
712 |
// /// Defalult constructor.
|
klao@946
|
713 |
|
klao@946
|
714 |
// /// Defalult constructor.
|
klao@946
|
715 |
// ///
|
klao@946
|
716 |
// ErasableGraph() { }
|
klao@946
|
717 |
// /// Deletes a node.
|
klao@946
|
718 |
|
klao@946
|
719 |
// /// Deletes node \c n node.
|
klao@946
|
720 |
// ///
|
klao@946
|
721 |
// void erase(Node n) { }
|
klao@946
|
722 |
// /// Deletes an edge.
|
klao@946
|
723 |
|
klao@946
|
724 |
// /// Deletes edge \c e edge.
|
klao@946
|
725 |
// ///
|
klao@946
|
726 |
// void erase(Edge e) { }
|
klao@946
|
727 |
// };
|
klao@946
|
728 |
|
klao@946
|
729 |
// template<class Graph> void checkCompileGraphEraseEdge(Graph &G)
|
klao@946
|
730 |
// {
|
klao@946
|
731 |
// typename Graph::Edge e;
|
klao@946
|
732 |
// G.erase(e);
|
klao@946
|
733 |
// }
|
klao@946
|
734 |
|
klao@946
|
735 |
// template<class Graph> void checkCompileGraphEraseNode(Graph &G)
|
klao@946
|
736 |
// {
|
klao@946
|
737 |
// typename Graph::Node n;
|
klao@946
|
738 |
// G.erase(n);
|
klao@946
|
739 |
// }
|
klao@946
|
740 |
|
klao@946
|
741 |
// ///\brief Checks whether \c G meets the
|
klao@946
|
742 |
// ///\ref lemon::skeleton::EresableGraph "EresableGraph" concept
|
klao@946
|
743 |
// template<class Graph> void checkCompileErasableGraph(Graph &G)
|
klao@946
|
744 |
// {
|
klao@946
|
745 |
// checkCompileExtendableGraph(G);
|
klao@946
|
746 |
// checkCompileGraphEraseNode(G);
|
klao@946
|
747 |
// checkCompileGraphEraseEdge(G);
|
klao@946
|
748 |
// }
|
klao@946
|
749 |
|
klao@946
|
750 |
// ///Checks whether a graph has findEdge() member function.
|
klao@946
|
751 |
|
klao@946
|
752 |
// ///\todo findEdge() might be a global function.
|
klao@946
|
753 |
// ///
|
klao@946
|
754 |
// template<class Graph> void checkCompileGraphFindEdge(Graph &G)
|
klao@946
|
755 |
// {
|
klao@946
|
756 |
// typedef typename Graph::NodeIt Node;
|
klao@946
|
757 |
// typedef typename Graph::NodeIt NodeIt;
|
klao@946
|
758 |
|
klao@946
|
759 |
// G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
|
klao@946
|
760 |
// G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));
|
klao@946
|
761 |
// }
|
klao@946
|
762 |
|
klao@946
|
763 |
|
klao@946
|
764 |
|
klao@946
|
765 |
/************* New GraphBase stuff **************/
|
klao@946
|
766 |
|
klao@946
|
767 |
|
klao@946
|
768 |
/// \bug The nodes and edges are not allowed to inherit from the
|
klao@946
|
769 |
/// same baseclass.
|
klao@946
|
770 |
|
klao@946
|
771 |
class BaseGraphItem {
|
alpar@732
|
772 |
public:
|
klao@946
|
773 |
BaseGraphItem() {}
|
klao@946
|
774 |
BaseGraphItem(Invalid) {}
|
alpar@801
|
775 |
|
klao@946
|
776 |
// We explicitely list these:
|
klao@946
|
777 |
BaseGraphItem(BaseGraphItem const&) {}
|
klao@946
|
778 |
BaseGraphItem& operator=(BaseGraphItem const&) { return *this; }
|
alpar@163
|
779 |
|
klao@946
|
780 |
bool operator==(BaseGraphItem) const { return false; }
|
klao@946
|
781 |
bool operator!=(BaseGraphItem) const { return false; }
|
alpar@732
|
782 |
|
klao@946
|
783 |
// Technical requirement. Do we really need this?
|
klao@946
|
784 |
bool operator<(BaseGraphItem) const { return false; }
|
alpar@163
|
785 |
};
|
alpar@163
|
786 |
|
klao@946
|
787 |
|
klao@946
|
788 |
/// A minimal GraphBase concept
|
klao@946
|
789 |
|
klao@946
|
790 |
/// This class describes a minimal concept which can be extended to a
|
klao@946
|
791 |
/// full-featured graph with \ref GraphFactory.
|
klao@946
|
792 |
class GraphBase {
|
klao@946
|
793 |
public:
|
klao@946
|
794 |
|
klao@946
|
795 |
GraphBase() {}
|
klao@946
|
796 |
|
klao@946
|
797 |
|
klao@946
|
798 |
/// \bug Nodes and Edges are comparable each other
|
klao@946
|
799 |
|
klao@946
|
800 |
class Node : public BaseGraphItem {};
|
klao@946
|
801 |
class Edge : public BaseGraphItem {};
|
klao@946
|
802 |
|
klao@946
|
803 |
// Graph operation
|
klao@946
|
804 |
void firstNode(Node &n) const { }
|
klao@946
|
805 |
void firstEdge(Edge &e) const { }
|
klao@946
|
806 |
|
klao@946
|
807 |
void firstOutEdge(Edge &e, Node) const { }
|
klao@946
|
808 |
void firstInEdge(Edge &e, Node) const { }
|
klao@946
|
809 |
|
klao@946
|
810 |
void nextNode(Node &n) const { }
|
klao@946
|
811 |
void nextEdge(Edge &e) const { }
|
klao@946
|
812 |
|
klao@946
|
813 |
|
klao@946
|
814 |
// Question: isn't it reasonable if this methods have a Node
|
klao@946
|
815 |
// parameter? Like this:
|
klao@946
|
816 |
// Edge& nextOut(Edge &e, Node) const { return e; }
|
klao@946
|
817 |
void nextOutEdge(Edge &e) const { }
|
klao@946
|
818 |
void nextInEdge(Edge &e) const { }
|
klao@946
|
819 |
|
klao@946
|
820 |
Node head(Edge) const { return Node(); }
|
klao@946
|
821 |
Node tail(Edge) const { return Node(); }
|
klao@946
|
822 |
|
klao@946
|
823 |
|
klao@946
|
824 |
// Do we need id, nodeNum, edgeNum and co. in this basic graphbase
|
klao@946
|
825 |
// concept?
|
klao@946
|
826 |
|
klao@946
|
827 |
|
klao@946
|
828 |
// Maps.
|
klao@946
|
829 |
//
|
klao@946
|
830 |
// We need a special slimer concept which does not provide maps (it
|
klao@946
|
831 |
// wouldn't be strictly slimer, cause for map-factory id() & friends
|
klao@946
|
832 |
// a required...)
|
klao@946
|
833 |
|
klao@946
|
834 |
template<typename T>
|
klao@946
|
835 |
class NodeMap : public GraphMap<Node, T, GraphBase> {};
|
klao@946
|
836 |
|
klao@946
|
837 |
template<typename T>
|
klao@946
|
838 |
class EdgeMap : public GraphMap<Edge, T, GraphBase> {};
|
alpar@938
|
839 |
};
|
alpar@186
|
840 |
|
klao@946
|
841 |
|
klao@946
|
842 |
|
klao@946
|
843 |
/**************** Concept checking classes ****************/
|
klao@946
|
844 |
|
klao@946
|
845 |
template<typename BGI>
|
klao@946
|
846 |
struct BaseGraphItemConcept {
|
klao@946
|
847 |
void constraints() {
|
klao@946
|
848 |
BGI i1;
|
klao@946
|
849 |
BGI i2 = i1;
|
klao@946
|
850 |
BGI i3 = INVALID;
|
klao@946
|
851 |
|
klao@946
|
852 |
i1 = i3;
|
klao@946
|
853 |
if( i1 == i3 ) {
|
klao@946
|
854 |
if ( i2 != i3 && i3 < i2 )
|
klao@946
|
855 |
return;
|
alpar@938
|
856 |
}
|
alpar@938
|
857 |
}
|
alpar@163
|
858 |
};
|
alpar@163
|
859 |
|
alpar@938
|
860 |
|
klao@946
|
861 |
|
klao@946
|
862 |
class StaticGraph
|
klao@946
|
863 |
: virtual public BaseGraphComponent, public IterableGraphComponent, public MappableGraphComponent {
|
klao@946
|
864 |
public:
|
klao@946
|
865 |
typedef BaseGraphComponent::Node Node;
|
klao@946
|
866 |
typedef BaseGraphComponent::Edge Edge;
|
klao@946
|
867 |
};
|
alpar@938
|
868 |
|
klao@946
|
869 |
template <typename Graph>
|
klao@946
|
870 |
struct StaticGraphConcept {
|
klao@946
|
871 |
void constraints() {
|
klao@946
|
872 |
function_requires<BaseGraphComponentConcept<Graph> >();
|
klao@946
|
873 |
function_requires<IterableGraphComponentConcept<Graph> >();
|
klao@946
|
874 |
function_requires<MappableGraphComponentConcept<Graph> >();
|
klao@946
|
875 |
}
|
klao@946
|
876 |
Graph& graph;
|
klao@946
|
877 |
};
|
alpar@938
|
878 |
|
klao@946
|
879 |
class ExtendableGraph
|
klao@946
|
880 |
: virtual public BaseGraphComponent, public StaticGraph, public ExtendableGraphComponent, public ClearableGraphComponent {
|
klao@946
|
881 |
public:
|
klao@946
|
882 |
typedef BaseGraphComponent::Node Node;
|
klao@946
|
883 |
typedef BaseGraphComponent::Edge Edge;
|
klao@946
|
884 |
};
|
alpar@938
|
885 |
|
klao@946
|
886 |
template <typename Graph>
|
klao@946
|
887 |
struct ExtendableGraphConcept {
|
klao@946
|
888 |
void constraints() {
|
klao@946
|
889 |
function_requires<StaticGraphConcept<Graph> >();
|
klao@946
|
890 |
function_requires<ExtendableGraphComponentConcept<Graph> >();
|
klao@946
|
891 |
function_requires<ClearableGraphComponentConcept<Graph> >();
|
klao@946
|
892 |
}
|
klao@946
|
893 |
Graph& graph;
|
klao@946
|
894 |
};
|
klao@946
|
895 |
|
klao@946
|
896 |
class ErasableGraph
|
klao@946
|
897 |
: virtual public BaseGraphComponent, public ExtendableGraph, public ErasableGraphComponent {
|
alpar@163
|
898 |
public:
|
klao@946
|
899 |
typedef BaseGraphComponent::Node Node;
|
klao@946
|
900 |
typedef BaseGraphComponent::Edge Edge;
|
klao@946
|
901 |
};
|
alpar@801
|
902 |
|
klao@946
|
903 |
template <typename Graph>
|
klao@946
|
904 |
struct ErasableGraphConcept {
|
klao@946
|
905 |
void constraints() {
|
klao@946
|
906 |
function_requires<ExtendableGraphConcept<Graph> >();
|
klao@946
|
907 |
function_requires<ErasableGraphComponentConcept<Graph> >();
|
klao@946
|
908 |
}
|
klao@946
|
909 |
Graph& graph;
|
klao@946
|
910 |
};
|
alpar@801
|
911 |
|
alpar@732
|
912 |
// @}
|
alpar@801
|
913 |
} //namespace skeleton
|
alpar@921
|
914 |
} //namespace lemon
|
alpar@52
|
915 |
|
alpar@145
|
916 |
|
alpar@145
|
917 |
|
alpar@921
|
918 |
#endif // LEMON_SKELETON_GRAPH_H
|