klao@959
|
1 |
/* -*- C++ -*-
|
klao@959
|
2 |
*
|
alpar@1956
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@1956
|
4 |
*
|
alpar@1956
|
5 |
* Copyright (C) 2003-2006
|
alpar@1956
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@1359
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
klao@959
|
8 |
*
|
klao@959
|
9 |
* Permission to use, modify and distribute this software is granted
|
klao@959
|
10 |
* provided that this copyright notice appears in all copies. For
|
klao@959
|
11 |
* precise terms see the accompanying LICENSE file.
|
klao@959
|
12 |
*
|
klao@959
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
klao@959
|
14 |
* express or implied, and with no claim as to its suitability for any
|
klao@959
|
15 |
* purpose.
|
klao@959
|
16 |
*
|
klao@959
|
17 |
*/
|
klao@959
|
18 |
|
klao@959
|
19 |
#ifndef LEMON_CONCEPT_GRAPH_H
|
klao@959
|
20 |
#define LEMON_CONCEPT_GRAPH_H
|
klao@959
|
21 |
|
klao@1030
|
22 |
///\ingroup graph_concepts
|
klao@959
|
23 |
///\file
|
klao@959
|
24 |
///\brief Declaration of Graph.
|
klao@959
|
25 |
|
deba@1993
|
26 |
#include <lemon/bits/invalid.h>
|
deba@1993
|
27 |
#include <lemon/bits/utility.h>
|
klao@959
|
28 |
#include <lemon/concept/maps.h>
|
klao@959
|
29 |
#include <lemon/concept_check.h>
|
klao@959
|
30 |
#include <lemon/concept/graph_component.h>
|
klao@959
|
31 |
|
klao@959
|
32 |
namespace lemon {
|
klao@959
|
33 |
namespace concept {
|
deba@1136
|
34 |
|
klao@959
|
35 |
|
klao@961
|
36 |
/**************** The full-featured graph concepts ****************/
|
klao@959
|
37 |
|
deba@1136
|
38 |
|
klao@1760
|
39 |
// \brief Modular static graph class.
|
klao@1760
|
40 |
//
|
klao@1760
|
41 |
// It should be the same as the \c StaticGraph class.
|
deba@1136
|
42 |
class _StaticGraph
|
klao@961
|
43 |
: virtual public BaseGraphComponent,
|
ladanyi@1426
|
44 |
public IterableGraphComponent, public MappableGraphComponent {
|
klao@959
|
45 |
public:
|
alpar@1448
|
46 |
|
klao@959
|
47 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
48 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
49 |
|
deba@989
|
50 |
template <typename _Graph>
|
deba@989
|
51 |
struct Constraints {
|
ladanyi@1426
|
52 |
void constraints() {
|
ladanyi@1426
|
53 |
checkConcept<IterableGraphComponent, _Graph>();
|
ladanyi@1426
|
54 |
checkConcept<MappableGraphComponent, _Graph>();
|
ladanyi@1426
|
55 |
}
|
deba@989
|
56 |
};
|
klao@959
|
57 |
};
|
klao@959
|
58 |
|
klao@1760
|
59 |
// \brief Modular extendable graph class.
|
klao@1760
|
60 |
//
|
klao@1760
|
61 |
// It should be the same as the \c ExtendableGraph class.
|
deba@1136
|
62 |
class _ExtendableGraph
|
deba@1136
|
63 |
: virtual public BaseGraphComponent, public _StaticGraph,
|
ladanyi@1426
|
64 |
public ExtendableGraphComponent, public ClearableGraphComponent {
|
klao@959
|
65 |
public:
|
klao@959
|
66 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
67 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
68 |
|
deba@989
|
69 |
template <typename _Graph>
|
deba@989
|
70 |
struct Constraints {
|
ladanyi@1426
|
71 |
void constraints() {
|
ladanyi@1426
|
72 |
checkConcept<_StaticGraph, _Graph >();
|
ladanyi@1426
|
73 |
checkConcept<ExtendableGraphComponent, _Graph >();
|
ladanyi@1426
|
74 |
checkConcept<ClearableGraphComponent, _Graph >();
|
ladanyi@1426
|
75 |
}
|
deba@989
|
76 |
};
|
klao@959
|
77 |
};
|
klao@959
|
78 |
|
klao@1760
|
79 |
// \brief Modular erasable graph class.
|
klao@1760
|
80 |
//
|
klao@1760
|
81 |
// It should be the same as the \c ErasableGraph class.
|
deba@1136
|
82 |
class _ErasableGraph
|
deba@1136
|
83 |
: virtual public BaseGraphComponent, public _ExtendableGraph,
|
ladanyi@1426
|
84 |
public ErasableGraphComponent {
|
klao@959
|
85 |
public:
|
klao@959
|
86 |
typedef BaseGraphComponent::Node Node;
|
klao@959
|
87 |
typedef BaseGraphComponent::Edge Edge;
|
klao@959
|
88 |
|
deba@989
|
89 |
template <typename _Graph>
|
deba@989
|
90 |
struct Constraints {
|
ladanyi@1426
|
91 |
void constraints() {
|
ladanyi@1426
|
92 |
checkConcept<_ExtendableGraph, _Graph >();
|
ladanyi@1426
|
93 |
checkConcept<ErasableGraphComponent, _Graph >();
|
ladanyi@1426
|
94 |
}
|
deba@989
|
95 |
};
|
klao@959
|
96 |
};
|
klao@959
|
97 |
|
alpar@1620
|
98 |
/// \addtogroup graph_concepts
|
alpar@1620
|
99 |
/// @{
|
alpar@1620
|
100 |
|
deba@1136
|
101 |
/// An empty static graph class.
|
deba@1136
|
102 |
|
deba@1136
|
103 |
/// This class provides all the common features of a graph structure,
|
deba@1136
|
104 |
/// however completely without implementations and real data structures
|
deba@1136
|
105 |
/// behind the interface.
|
deba@1136
|
106 |
/// All graph algorithms should compile with this class, but it will not
|
deba@1136
|
107 |
/// run properly, of course.
|
deba@1136
|
108 |
///
|
deba@1136
|
109 |
/// It can be used for checking the interface compatibility,
|
deba@1136
|
110 |
/// or it can serve as a skeleton of a new graph structure.
|
deba@1136
|
111 |
///
|
deba@1136
|
112 |
/// Also, you will find here the full documentation of a certain graph
|
deba@1136
|
113 |
/// feature, the documentation of a real graph imlementation
|
deba@1136
|
114 |
/// like @ref ListGraph or
|
deba@1136
|
115 |
/// @ref SmartGraph will just refer to this structure.
|
deba@1136
|
116 |
///
|
deba@1136
|
117 |
/// \todo A pages describing the concept of concept description would
|
deba@1136
|
118 |
/// be nice.
|
deba@1136
|
119 |
class StaticGraph
|
deba@1136
|
120 |
{
|
deba@1136
|
121 |
public:
|
alpar@1448
|
122 |
///\e
|
alpar@1448
|
123 |
|
deba@1136
|
124 |
/// Defalult constructor.
|
deba@1136
|
125 |
|
deba@1136
|
126 |
/// Defalult constructor.
|
deba@1136
|
127 |
///
|
deba@1136
|
128 |
StaticGraph() { }
|
deba@1136
|
129 |
///Copy consructor.
|
deba@1136
|
130 |
|
deba@1136
|
131 |
// ///\todo It is not clear, what we expect from a copy constructor.
|
deba@1136
|
132 |
// ///E.g. How to assign the nodes/edges to each other? What about maps?
|
deba@1136
|
133 |
// StaticGraph(const StaticGraph& g) { }
|
deba@1136
|
134 |
|
deba@1136
|
135 |
/// The base type of node iterators,
|
deba@1136
|
136 |
/// or in other words, the trivial node iterator.
|
deba@1136
|
137 |
|
deba@1136
|
138 |
/// This is the base type of each node iterator,
|
deba@1136
|
139 |
/// thus each kind of node iterator converts to this.
|
deba@1136
|
140 |
/// More precisely each kind of node iterator should be inherited
|
deba@1136
|
141 |
/// from the trivial node iterator.
|
deba@1136
|
142 |
class Node {
|
deba@1136
|
143 |
public:
|
ladanyi@1426
|
144 |
/// Default constructor
|
deba@1136
|
145 |
|
ladanyi@1426
|
146 |
/// @warning The default constructor sets the iterator
|
ladanyi@1426
|
147 |
/// to an undefined value.
|
ladanyi@1426
|
148 |
Node() { }
|
ladanyi@1426
|
149 |
/// Copy constructor.
|
deba@1136
|
150 |
|
ladanyi@1426
|
151 |
/// Copy constructor.
|
ladanyi@1426
|
152 |
///
|
ladanyi@1426
|
153 |
Node(const Node&) { }
|
deba@1136
|
154 |
|
ladanyi@1426
|
155 |
/// Invalid constructor \& conversion.
|
deba@1136
|
156 |
|
ladanyi@1426
|
157 |
/// This constructor initializes the iterator to be invalid.
|
ladanyi@1426
|
158 |
/// \sa Invalid for more details.
|
ladanyi@1426
|
159 |
Node(Invalid) { }
|
ladanyi@1426
|
160 |
/// Equality operator
|
deba@1136
|
161 |
|
ladanyi@1426
|
162 |
/// Two iterators are equal if and only if they point to the
|
ladanyi@1426
|
163 |
/// same object or both are invalid.
|
ladanyi@1426
|
164 |
bool operator==(Node) const { return true; }
|
deba@1136
|
165 |
|
ladanyi@1426
|
166 |
/// Inequality operator
|
ladanyi@1426
|
167 |
|
ladanyi@1426
|
168 |
/// \sa operator==(Node n)
|
ladanyi@1426
|
169 |
///
|
ladanyi@1426
|
170 |
bool operator!=(Node) const { return true; }
|
deba@1136
|
171 |
|
deba@1622
|
172 |
/// Artificial ordering operator.
|
deba@1622
|
173 |
|
deba@1622
|
174 |
/// To allow the use of graph descriptors as key type in std::map or
|
deba@1622
|
175 |
/// similar associative container we require this.
|
deba@1622
|
176 |
///
|
deba@1622
|
177 |
/// \note This operator only have to define some strict ordering of
|
deba@1622
|
178 |
/// the items; this order has nothing to do with the iteration
|
deba@1622
|
179 |
/// ordering of the items.
|
deba@1622
|
180 |
///
|
deba@1622
|
181 |
/// \bug This is a technical requirement. Do we really need this?
|
deba@1622
|
182 |
bool operator<(Node) const { return false; }
|
deba@1622
|
183 |
|
deba@1136
|
184 |
};
|
deba@1136
|
185 |
|
deba@1136
|
186 |
/// This iterator goes through each node.
|
deba@1136
|
187 |
|
deba@1136
|
188 |
/// This iterator goes through each node.
|
deba@1136
|
189 |
/// Its usage is quite simple, for example you can count the number
|
deba@1136
|
190 |
/// of nodes in graph \c g of type \c Graph like this:
|
alpar@1946
|
191 |
///\code
|
deba@1136
|
192 |
/// int count=0;
|
ladanyi@1426
|
193 |
/// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
|
alpar@1946
|
194 |
///\endcode
|
deba@1136
|
195 |
class NodeIt : public Node {
|
deba@1136
|
196 |
public:
|
ladanyi@1426
|
197 |
/// Default constructor
|
deba@1136
|
198 |
|
ladanyi@1426
|
199 |
/// @warning The default constructor sets the iterator
|
ladanyi@1426
|
200 |
/// to an undefined value.
|
ladanyi@1426
|
201 |
NodeIt() { }
|
ladanyi@1426
|
202 |
/// Copy constructor.
|
ladanyi@1426
|
203 |
|
ladanyi@1426
|
204 |
/// Copy constructor.
|
ladanyi@1426
|
205 |
///
|
ladanyi@1426
|
206 |
NodeIt(const NodeIt& n) : Node(n) { }
|
ladanyi@1426
|
207 |
/// Invalid constructor \& conversion.
|
deba@1136
|
208 |
|
ladanyi@1426
|
209 |
/// Initialize the iterator to be invalid.
|
ladanyi@1426
|
210 |
/// \sa Invalid for more details.
|
ladanyi@1426
|
211 |
NodeIt(Invalid) { }
|
ladanyi@1426
|
212 |
/// Sets the iterator to the first node.
|
deba@1136
|
213 |
|
ladanyi@1426
|
214 |
/// Sets the iterator to the first node of \c g.
|
ladanyi@1426
|
215 |
///
|
ladanyi@1426
|
216 |
NodeIt(const StaticGraph&) { }
|
ladanyi@1426
|
217 |
/// Node -> NodeIt conversion.
|
deba@1136
|
218 |
|
deba@1470
|
219 |
/// Sets the iterator to the node of \c the graph pointed by
|
deba@1470
|
220 |
/// the trivial iterator.
|
ladanyi@1426
|
221 |
/// This feature necessitates that each time we
|
ladanyi@1426
|
222 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1470
|
223 |
NodeIt(const StaticGraph&, const Node&) { }
|
ladanyi@1426
|
224 |
/// Next node.
|
deba@1136
|
225 |
|
ladanyi@1426
|
226 |
/// Assign the iterator to the next node.
|
ladanyi@1426
|
227 |
///
|
ladanyi@1426
|
228 |
NodeIt& operator++() { return *this; }
|
deba@1136
|
229 |
};
|
deba@1136
|
230 |
|
deba@1136
|
231 |
|
deba@1136
|
232 |
/// The base type of the edge iterators.
|
deba@1136
|
233 |
|
deba@1136
|
234 |
/// The base type of the edge iterators.
|
deba@1136
|
235 |
///
|
deba@1136
|
236 |
class Edge {
|
deba@1136
|
237 |
public:
|
ladanyi@1426
|
238 |
/// Default constructor
|
deba@1136
|
239 |
|
ladanyi@1426
|
240 |
/// @warning The default constructor sets the iterator
|
ladanyi@1426
|
241 |
/// to an undefined value.
|
ladanyi@1426
|
242 |
Edge() { }
|
ladanyi@1426
|
243 |
/// Copy constructor.
|
deba@1136
|
244 |
|
ladanyi@1426
|
245 |
/// Copy constructor.
|
ladanyi@1426
|
246 |
///
|
ladanyi@1426
|
247 |
Edge(const Edge&) { }
|
ladanyi@1426
|
248 |
/// Initialize the iterator to be invalid.
|
deba@1136
|
249 |
|
ladanyi@1426
|
250 |
/// Initialize the iterator to be invalid.
|
ladanyi@1426
|
251 |
///
|
ladanyi@1426
|
252 |
Edge(Invalid) { }
|
ladanyi@1426
|
253 |
/// Equality operator
|
deba@1136
|
254 |
|
ladanyi@1426
|
255 |
/// Two iterators are equal if and only if they point to the
|
ladanyi@1426
|
256 |
/// same object or both are invalid.
|
ladanyi@1426
|
257 |
bool operator==(Edge) const { return true; }
|
ladanyi@1426
|
258 |
/// Inequality operator
|
deba@1136
|
259 |
|
alpar@1620
|
260 |
/// \sa operator==(Edge n)
|
ladanyi@1426
|
261 |
///
|
ladanyi@1426
|
262 |
bool operator!=(Edge) const { return true; }
|
deba@1622
|
263 |
|
deba@1622
|
264 |
/// Artificial ordering operator.
|
deba@1622
|
265 |
|
deba@1622
|
266 |
/// To allow the use of graph descriptors as key type in std::map or
|
deba@1622
|
267 |
/// similar associative container we require this.
|
deba@1622
|
268 |
///
|
deba@1622
|
269 |
/// \note This operator only have to define some strict ordering of
|
deba@1622
|
270 |
/// the items; this order has nothing to do with the iteration
|
deba@1622
|
271 |
/// ordering of the items.
|
deba@1622
|
272 |
///
|
deba@1622
|
273 |
/// \bug This is a technical requirement. Do we really need this?
|
deba@1622
|
274 |
bool operator<(Edge) const { return false; }
|
deba@1136
|
275 |
};
|
deba@1136
|
276 |
|
deba@1136
|
277 |
/// This iterator goes trough the outgoing edges of a node.
|
deba@1136
|
278 |
|
deba@1136
|
279 |
/// This iterator goes trough the \e outgoing edges of a certain node
|
deba@1136
|
280 |
/// of a graph.
|
deba@1136
|
281 |
/// Its usage is quite simple, for example you can count the number
|
deba@1136
|
282 |
/// of outgoing edges of a node \c n
|
deba@1136
|
283 |
/// in graph \c g of type \c Graph as follows.
|
alpar@1946
|
284 |
///\code
|
deba@1136
|
285 |
/// int count=0;
|
deba@1136
|
286 |
/// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
alpar@1946
|
287 |
///\endcode
|
deba@1136
|
288 |
|
deba@1136
|
289 |
class OutEdgeIt : public Edge {
|
deba@1136
|
290 |
public:
|
ladanyi@1426
|
291 |
/// Default constructor
|
deba@1136
|
292 |
|
ladanyi@1426
|
293 |
/// @warning The default constructor sets the iterator
|
ladanyi@1426
|
294 |
/// to an undefined value.
|
ladanyi@1426
|
295 |
OutEdgeIt() { }
|
ladanyi@1426
|
296 |
/// Copy constructor.
|
deba@1136
|
297 |
|
ladanyi@1426
|
298 |
/// Copy constructor.
|
ladanyi@1426
|
299 |
///
|
ladanyi@1426
|
300 |
OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
|
ladanyi@1426
|
301 |
/// Initialize the iterator to be invalid.
|
deba@1136
|
302 |
|
ladanyi@1426
|
303 |
/// Initialize the iterator to be invalid.
|
ladanyi@1426
|
304 |
///
|
ladanyi@1426
|
305 |
OutEdgeIt(Invalid) { }
|
ladanyi@1426
|
306 |
/// This constructor sets the iterator to the first outgoing edge.
|
deba@1136
|
307 |
|
ladanyi@1426
|
308 |
/// This constructor sets the iterator to the first outgoing edge of
|
ladanyi@1426
|
309 |
/// the node.
|
ladanyi@1426
|
310 |
OutEdgeIt(const StaticGraph&, const Node&) { }
|
ladanyi@1426
|
311 |
/// Edge -> OutEdgeIt conversion
|
deba@1136
|
312 |
|
deba@1470
|
313 |
/// Sets the iterator to the value of the trivial iterator.
|
deba@1470
|
314 |
/// This feature necessitates that each time we
|
ladanyi@1426
|
315 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1470
|
316 |
OutEdgeIt(const StaticGraph&, const Edge&) { }
|
ladanyi@1426
|
317 |
///Next outgoing edge
|
ladanyi@1426
|
318 |
|
ladanyi@1426
|
319 |
/// Assign the iterator to the next
|
ladanyi@1426
|
320 |
/// outgoing edge of the corresponding node.
|
ladanyi@1426
|
321 |
OutEdgeIt& operator++() { return *this; }
|
deba@1136
|
322 |
};
|
deba@1136
|
323 |
|
deba@1136
|
324 |
/// This iterator goes trough the incoming edges of a node.
|
deba@1136
|
325 |
|
deba@1136
|
326 |
/// This iterator goes trough the \e incoming edges of a certain node
|
deba@1136
|
327 |
/// of a graph.
|
deba@1136
|
328 |
/// Its usage is quite simple, for example you can count the number
|
deba@1136
|
329 |
/// of outgoing edges of a node \c n
|
deba@1136
|
330 |
/// in graph \c g of type \c Graph as follows.
|
alpar@1946
|
331 |
///\code
|
deba@1136
|
332 |
/// int count=0;
|
deba@1136
|
333 |
/// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
alpar@1946
|
334 |
///\endcode
|
deba@1136
|
335 |
|
deba@1136
|
336 |
class InEdgeIt : public Edge {
|
deba@1136
|
337 |
public:
|
ladanyi@1426
|
338 |
/// Default constructor
|
deba@1136
|
339 |
|
ladanyi@1426
|
340 |
/// @warning The default constructor sets the iterator
|
ladanyi@1426
|
341 |
/// to an undefined value.
|
ladanyi@1426
|
342 |
InEdgeIt() { }
|
ladanyi@1426
|
343 |
/// Copy constructor.
|
deba@1136
|
344 |
|
ladanyi@1426
|
345 |
/// Copy constructor.
|
ladanyi@1426
|
346 |
///
|
ladanyi@1426
|
347 |
InEdgeIt(const InEdgeIt& e) : Edge(e) { }
|
ladanyi@1426
|
348 |
/// Initialize the iterator to be invalid.
|
deba@1136
|
349 |
|
ladanyi@1426
|
350 |
/// Initialize the iterator to be invalid.
|
ladanyi@1426
|
351 |
///
|
ladanyi@1426
|
352 |
InEdgeIt(Invalid) { }
|
ladanyi@1426
|
353 |
/// This constructor sets the iterator to first incoming edge.
|
deba@1136
|
354 |
|
ladanyi@1426
|
355 |
/// This constructor set the iterator to the first incoming edge of
|
ladanyi@1426
|
356 |
/// the node.
|
ladanyi@1426
|
357 |
InEdgeIt(const StaticGraph&, const Node&) { }
|
ladanyi@1426
|
358 |
/// Edge -> InEdgeIt conversion
|
deba@1136
|
359 |
|
ladanyi@1426
|
360 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
ladanyi@1426
|
361 |
/// This feature necessitates that each time we
|
ladanyi@1426
|
362 |
/// iterate the edge-set, the iteration order is the same.
|
ladanyi@1426
|
363 |
InEdgeIt(const StaticGraph&, const Edge&) { }
|
ladanyi@1426
|
364 |
/// Next incoming edge
|
deba@1136
|
365 |
|
ladanyi@1426
|
366 |
/// Assign the iterator to the next inedge of the corresponding node.
|
ladanyi@1426
|
367 |
///
|
ladanyi@1426
|
368 |
InEdgeIt& operator++() { return *this; }
|
deba@1136
|
369 |
};
|
deba@1136
|
370 |
/// This iterator goes through each edge.
|
deba@1136
|
371 |
|
deba@1136
|
372 |
/// This iterator goes through each edge of a graph.
|
deba@1136
|
373 |
/// Its usage is quite simple, for example you can count the number
|
deba@1136
|
374 |
/// of edges in a graph \c g of type \c Graph as follows:
|
alpar@1946
|
375 |
///\code
|
deba@1136
|
376 |
/// int count=0;
|
deba@1136
|
377 |
/// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
|
alpar@1946
|
378 |
///\endcode
|
deba@1136
|
379 |
class EdgeIt : public Edge {
|
deba@1136
|
380 |
public:
|
ladanyi@1426
|
381 |
/// Default constructor
|
deba@1136
|
382 |
|
ladanyi@1426
|
383 |
/// @warning The default constructor sets the iterator
|
ladanyi@1426
|
384 |
/// to an undefined value.
|
ladanyi@1426
|
385 |
EdgeIt() { }
|
ladanyi@1426
|
386 |
/// Copy constructor.
|
deba@1136
|
387 |
|
ladanyi@1426
|
388 |
/// Copy constructor.
|
ladanyi@1426
|
389 |
///
|
ladanyi@1426
|
390 |
EdgeIt(const EdgeIt& e) : Edge(e) { }
|
ladanyi@1426
|
391 |
/// Initialize the iterator to be invalid.
|
deba@1136
|
392 |
|
ladanyi@1426
|
393 |
/// Initialize the iterator to be invalid.
|
ladanyi@1426
|
394 |
///
|
ladanyi@1426
|
395 |
EdgeIt(Invalid) { }
|
ladanyi@1426
|
396 |
/// This constructor sets the iterator to the first edge.
|
deba@1136
|
397 |
|
ladanyi@1426
|
398 |
/// This constructor sets the iterator to the first edge of \c g.
|
ladanyi@1426
|
399 |
///@param g the graph
|
alpar@1643
|
400 |
EdgeIt(const StaticGraph& g) { ignore_unused_variable_warning(g); }
|
ladanyi@1426
|
401 |
/// Edge -> EdgeIt conversion
|
deba@1136
|
402 |
|
ladanyi@1426
|
403 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
ladanyi@1426
|
404 |
/// This feature necessitates that each time we
|
ladanyi@1426
|
405 |
/// iterate the edge-set, the iteration order is the same.
|
ladanyi@1426
|
406 |
EdgeIt(const StaticGraph&, const Edge&) { }
|
ladanyi@1426
|
407 |
///Next edge
|
ladanyi@1426
|
408 |
|
ladanyi@1426
|
409 |
/// Assign the iterator to the next edge.
|
ladanyi@1426
|
410 |
EdgeIt& operator++() { return *this; }
|
deba@1136
|
411 |
};
|
deba@1136
|
412 |
///Gives back the target node of an edge.
|
deba@1136
|
413 |
|
deba@1136
|
414 |
///Gives back the target node of an edge.
|
deba@1136
|
415 |
///
|
deba@1136
|
416 |
Node target(Edge) const { return INVALID; }
|
deba@1136
|
417 |
///Gives back the source node of an edge.
|
deba@1136
|
418 |
|
deba@1136
|
419 |
///Gives back the source node of an edge.
|
deba@1136
|
420 |
///
|
deba@1136
|
421 |
Node source(Edge) const { return INVALID; }
|
deba@1563
|
422 |
|
alpar@1630
|
423 |
// /// Gives back the first Node in the iterating order.
|
deba@1563
|
424 |
|
alpar@1630
|
425 |
// /// Gives back the first Node in the iterating order.
|
alpar@1630
|
426 |
// ///
|
deba@1563
|
427 |
void first(Node&) const {}
|
deba@1563
|
428 |
|
alpar@1630
|
429 |
// /// Gives back the next Node in the iterating order.
|
deba@1563
|
430 |
|
alpar@1630
|
431 |
// /// Gives back the next Node in the iterating order.
|
alpar@1630
|
432 |
// ///
|
deba@1563
|
433 |
void next(Node&) const {}
|
deba@1563
|
434 |
|
alpar@1630
|
435 |
// /// Gives back the first Edge in the iterating order.
|
deba@1563
|
436 |
|
alpar@1630
|
437 |
// /// Gives back the first Edge in the iterating order.
|
alpar@1630
|
438 |
// ///
|
deba@1563
|
439 |
void first(Edge&) const {}
|
alpar@1630
|
440 |
// /// Gives back the next Edge in the iterating order.
|
deba@1563
|
441 |
|
alpar@1630
|
442 |
// /// Gives back the next Edge in the iterating order.
|
alpar@1630
|
443 |
// ///
|
deba@1563
|
444 |
void next(Edge&) const {}
|
deba@1563
|
445 |
|
deba@1563
|
446 |
|
alpar@1630
|
447 |
// /// Gives back the first of the Edges point to the given Node.
|
deba@1563
|
448 |
|
alpar@1630
|
449 |
// /// Gives back the first of the Edges point to the given Node.
|
alpar@1630
|
450 |
// ///
|
deba@1563
|
451 |
void firstIn(Edge&, const Node&) const {}
|
deba@1563
|
452 |
|
alpar@1630
|
453 |
// /// Gives back the next of the Edges points to the given Node.
|
deba@1563
|
454 |
|
deba@1563
|
455 |
|
alpar@1630
|
456 |
// /// Gives back the next of the Edges points to the given Node.
|
alpar@1630
|
457 |
// ///
|
deba@1563
|
458 |
void nextIn(Edge&) const {}
|
deba@1563
|
459 |
|
alpar@1630
|
460 |
// /// Gives back the first of the Edges start from the given Node.
|
deba@1563
|
461 |
|
alpar@1630
|
462 |
// /// Gives back the first of the Edges start from the given Node.
|
alpar@1630
|
463 |
// ///
|
deba@1563
|
464 |
void firstOut(Edge&, const Node&) const {}
|
deba@1563
|
465 |
|
alpar@1630
|
466 |
// /// Gives back the next of the Edges start from the given Node.
|
deba@1563
|
467 |
|
alpar@1630
|
468 |
// /// Gives back the next of the Edges start from the given Node.
|
alpar@1630
|
469 |
// ///
|
deba@1563
|
470 |
void nextOut(Edge&) const {}
|
deba@1563
|
471 |
|
deba@1563
|
472 |
/// \brief The base node of the iterator.
|
deba@1563
|
473 |
///
|
deba@1563
|
474 |
/// Gives back the base node of the iterator.
|
deba@1627
|
475 |
/// It is always the target of the pointed edge.
|
deba@1563
|
476 |
Node baseNode(const InEdgeIt&) const { return INVALID; }
|
deba@1563
|
477 |
|
deba@1563
|
478 |
/// \brief The running node of the iterator.
|
deba@1563
|
479 |
///
|
deba@1563
|
480 |
/// Gives back the running node of the iterator.
|
deba@1627
|
481 |
/// It is always the source of the pointed edge.
|
deba@1563
|
482 |
Node runningNode(const InEdgeIt&) const { return INVALID; }
|
deba@1563
|
483 |
|
deba@1563
|
484 |
/// \brief The base node of the iterator.
|
deba@1563
|
485 |
///
|
deba@1563
|
486 |
/// Gives back the base node of the iterator.
|
deba@1627
|
487 |
/// It is always the source of the pointed edge.
|
deba@1563
|
488 |
Node baseNode(const OutEdgeIt&) const { return INVALID; }
|
deba@1563
|
489 |
|
deba@1563
|
490 |
/// \brief The running node of the iterator.
|
deba@1563
|
491 |
///
|
deba@1563
|
492 |
/// Gives back the running node of the iterator.
|
deba@1627
|
493 |
/// It is always the target of the pointed edge.
|
deba@1563
|
494 |
Node runningNode(const OutEdgeIt&) const { return INVALID; }
|
deba@1136
|
495 |
|
deba@1627
|
496 |
/// \brief The opposite node on the given edge.
|
deba@1627
|
497 |
///
|
deba@1627
|
498 |
/// Gives back the opposite node on the given edge.
|
deba@1627
|
499 |
Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
|
deba@1627
|
500 |
|
deba@1627
|
501 |
/// \brief Read write map of the nodes to type \c T.
|
deba@1627
|
502 |
///
|
deba@1136
|
503 |
/// ReadWrite map of the nodes to type \c T.
|
deba@1136
|
504 |
/// \sa Reference
|
deba@1136
|
505 |
/// \warning Making maps that can handle bool type (NodeMap<bool>)
|
deba@1136
|
506 |
/// needs some extra attention!
|
alpar@1630
|
507 |
/// \todo Wrong documentation
|
deba@1136
|
508 |
template<class T>
|
deba@1136
|
509 |
class NodeMap : public ReadWriteMap< Node, T >
|
deba@1136
|
510 |
{
|
deba@1136
|
511 |
public:
|
deba@1136
|
512 |
|
ladanyi@1426
|
513 |
///\e
|
ladanyi@1426
|
514 |
NodeMap(const StaticGraph&) { }
|
ladanyi@1426
|
515 |
///\e
|
ladanyi@1426
|
516 |
NodeMap(const StaticGraph&, T) { }
|
deba@1136
|
517 |
|
ladanyi@1426
|
518 |
///Copy constructor
|
ladanyi@1426
|
519 |
NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
ladanyi@1426
|
520 |
///Assignment operator
|
ladanyi@1426
|
521 |
NodeMap& operator=(const NodeMap&) { return *this; }
|
ladanyi@1426
|
522 |
// \todo fix this concept
|
deba@1136
|
523 |
};
|
deba@1136
|
524 |
|
deba@1627
|
525 |
/// \brief Read write map of the edges to type \c T.
|
deba@1627
|
526 |
///
|
deba@1627
|
527 |
/// Reference map of the edges to type \c T.
|
deba@1136
|
528 |
/// \sa Reference
|
deba@1136
|
529 |
/// \warning Making maps that can handle bool type (EdgeMap<bool>)
|
deba@1136
|
530 |
/// needs some extra attention!
|
alpar@1630
|
531 |
/// \todo Wrong documentation
|
deba@1136
|
532 |
template<class T>
|
deba@1136
|
533 |
class EdgeMap : public ReadWriteMap<Edge,T>
|
deba@1136
|
534 |
{
|
deba@1136
|
535 |
public:
|
deba@1136
|
536 |
|
ladanyi@1426
|
537 |
///\e
|
ladanyi@1426
|
538 |
EdgeMap(const StaticGraph&) { }
|
ladanyi@1426
|
539 |
///\e
|
ladanyi@1426
|
540 |
EdgeMap(const StaticGraph&, T) { }
|
ladanyi@1426
|
541 |
///Copy constructor
|
ladanyi@1426
|
542 |
EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
|
ladanyi@1426
|
543 |
///Assignment operator
|
ladanyi@1426
|
544 |
EdgeMap& operator=(const EdgeMap&) { return *this; }
|
ladanyi@1426
|
545 |
// \todo fix this concept
|
deba@1136
|
546 |
};
|
deba@1136
|
547 |
|
deba@1136
|
548 |
template <typename _Graph>
|
deba@1136
|
549 |
struct Constraints : public _StaticGraph::Constraints<_Graph> {};
|
deba@1136
|
550 |
|
deba@1136
|
551 |
};
|
deba@1136
|
552 |
|
deba@1136
|
553 |
/// An empty non-static graph class.
|
deba@1136
|
554 |
|
ladanyi@1426
|
555 |
/// This class provides everything that \ref StaticGraph does.
|
ladanyi@1426
|
556 |
/// Additionally it enables building graphs from scratch.
|
deba@1136
|
557 |
class ExtendableGraph : public StaticGraph
|
deba@1136
|
558 |
{
|
deba@1136
|
559 |
public:
|
deba@1136
|
560 |
/// Defalult constructor.
|
deba@1136
|
561 |
|
deba@1136
|
562 |
/// Defalult constructor.
|
deba@1136
|
563 |
///
|
deba@1136
|
564 |
ExtendableGraph() { }
|
deba@1136
|
565 |
///Add a new node to the graph.
|
deba@1136
|
566 |
|
deba@1136
|
567 |
/// \return the new node.
|
deba@1136
|
568 |
///
|
deba@1136
|
569 |
Node addNode() { return INVALID; }
|
deba@1136
|
570 |
///Add a new edge to the graph.
|
deba@1136
|
571 |
|
deba@1136
|
572 |
///Add a new edge to the graph with source node \c s
|
deba@1136
|
573 |
///and target node \c t.
|
deba@1136
|
574 |
///\return the new edge.
|
alpar@1367
|
575 |
Edge addEdge(Node, Node) { return INVALID; }
|
deba@1136
|
576 |
|
deba@1136
|
577 |
/// Resets the graph.
|
deba@1136
|
578 |
|
deba@1136
|
579 |
/// This function deletes all edges and nodes of the graph.
|
deba@1136
|
580 |
/// It also frees the memory allocated to store them.
|
deba@1136
|
581 |
/// \todo It might belong to \ref ErasableGraph.
|
deba@1136
|
582 |
void clear() { }
|
deba@1136
|
583 |
|
deba@1136
|
584 |
template <typename _Graph>
|
deba@1136
|
585 |
struct Constraints : public _ExtendableGraph::Constraints<_Graph> {};
|
deba@1136
|
586 |
|
deba@1136
|
587 |
};
|
deba@1136
|
588 |
|
deba@1136
|
589 |
/// An empty erasable graph class.
|
deba@1136
|
590 |
|
ladanyi@1426
|
591 |
/// This class is an extension of \ref ExtendableGraph. It makes it
|
deba@1136
|
592 |
/// possible to erase edges or nodes.
|
deba@1136
|
593 |
class ErasableGraph : public ExtendableGraph
|
deba@1136
|
594 |
{
|
deba@1136
|
595 |
public:
|
deba@1136
|
596 |
/// Defalult constructor.
|
deba@1136
|
597 |
|
deba@1136
|
598 |
/// Defalult constructor.
|
deba@1136
|
599 |
///
|
deba@1136
|
600 |
ErasableGraph() { }
|
deba@1136
|
601 |
/// Deletes a node.
|
deba@1136
|
602 |
|
deba@1136
|
603 |
/// Deletes node \c n node.
|
deba@1136
|
604 |
///
|
alpar@1367
|
605 |
void erase(Node) { }
|
deba@1136
|
606 |
/// Deletes an edge.
|
deba@1136
|
607 |
|
deba@1136
|
608 |
/// Deletes edge \c e edge.
|
deba@1136
|
609 |
///
|
alpar@1367
|
610 |
void erase(Edge) { }
|
deba@1136
|
611 |
|
deba@1136
|
612 |
template <typename _Graph>
|
deba@1136
|
613 |
struct Constraints : public _ErasableGraph::Constraints<_Graph> {};
|
deba@1136
|
614 |
|
deba@1136
|
615 |
};
|
deba@1136
|
616 |
|
klao@959
|
617 |
// @}
|
klao@959
|
618 |
} //namespace concept
|
klao@959
|
619 |
} //namespace lemon
|
klao@959
|
620 |
|
klao@959
|
621 |
|
klao@959
|
622 |
|
klao@959
|
623 |
#endif // LEMON_CONCEPT_GRAPH_H
|