klao@959
|
1 |
/* -*- C++ -*-
|
klao@959
|
2 |
* src/lemon/concept/graph.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@959
|
17 |
#ifndef LEMON_CONCEPT_SYM_GRAPH_H
|
klao@959
|
18 |
#define LEMON_CONCEPT_SYM_GRAPH_H
|
klao@959
|
19 |
|
klao@959
|
20 |
///\ingroup concept
|
klao@959
|
21 |
///\file
|
klao@959
|
22 |
///\brief Declaration of SymGraph.
|
klao@959
|
23 |
|
klao@959
|
24 |
#include <lemon/invalid.h>
|
klao@959
|
25 |
#include <lemon/concept/graph.h>
|
klao@959
|
26 |
#include <lemon/concept/maps.h>
|
klao@959
|
27 |
|
klao@959
|
28 |
namespace lemon {
|
klao@959
|
29 |
namespace concept {
|
klao@959
|
30 |
|
klao@959
|
31 |
/// \addtogroup concept
|
klao@959
|
32 |
/// @{
|
klao@959
|
33 |
|
klao@959
|
34 |
/// An empty static graph class.
|
klao@959
|
35 |
|
klao@959
|
36 |
/// This class provides all the common features of a symmetric
|
klao@959
|
37 |
/// graph structure, however completely without implementations and
|
klao@959
|
38 |
/// real data structures behind the interface.
|
klao@959
|
39 |
/// All graph algorithms should compile with this class, but it will not
|
klao@959
|
40 |
/// run properly, of course.
|
klao@959
|
41 |
///
|
klao@959
|
42 |
/// It can be used for checking the interface compatibility,
|
klao@959
|
43 |
/// or it can serve as a skeleton of a new symmetric graph structure.
|
klao@959
|
44 |
///
|
klao@959
|
45 |
/// Also, you will find here the full documentation of a certain graph
|
klao@959
|
46 |
/// feature, the documentation of a real symmetric graph imlementation
|
klao@959
|
47 |
/// like @ref SymListGraph or
|
klao@959
|
48 |
/// @ref lemon::SymSmartGraph will just refer to this structure.
|
klao@959
|
49 |
class StaticSymGraph
|
klao@959
|
50 |
{
|
klao@959
|
51 |
public:
|
klao@959
|
52 |
/// Defalult constructor.
|
klao@959
|
53 |
|
klao@959
|
54 |
/// Defalult constructor.
|
klao@959
|
55 |
///
|
klao@959
|
56 |
StaticSymGraph() { }
|
klao@959
|
57 |
///Copy consructor.
|
klao@959
|
58 |
|
klao@959
|
59 |
// ///\todo It is not clear, what we expect from a copy constructor.
|
klao@959
|
60 |
// ///E.g. How to assign the nodes/edges to each other? What about maps?
|
klao@959
|
61 |
// StaticGraph(const StaticGraph& g) { }
|
klao@959
|
62 |
|
klao@959
|
63 |
/// The base type of node iterators,
|
klao@959
|
64 |
/// or in other words, the trivial node iterator.
|
klao@959
|
65 |
|
klao@959
|
66 |
/// This is the base type of each node iterator,
|
klao@959
|
67 |
/// thus each kind of node iterator converts to this.
|
klao@959
|
68 |
/// More precisely each kind of node iterator should be inherited
|
klao@959
|
69 |
/// from the trivial node iterator.
|
klao@959
|
70 |
class Node {
|
klao@959
|
71 |
public:
|
klao@959
|
72 |
/// Default constructor
|
klao@959
|
73 |
|
klao@959
|
74 |
/// @warning The default constructor sets the iterator
|
klao@959
|
75 |
/// to an undefined value.
|
klao@959
|
76 |
Node() { }
|
klao@959
|
77 |
/// Copy constructor.
|
klao@959
|
78 |
|
klao@959
|
79 |
/// Copy constructor.
|
klao@959
|
80 |
///
|
klao@959
|
81 |
Node(const Node&) { }
|
klao@959
|
82 |
|
klao@959
|
83 |
/// Invalid constructor \& conversion.
|
klao@959
|
84 |
|
klao@959
|
85 |
/// This constructor initializes the iterator to be invalid.
|
klao@959
|
86 |
/// \sa Invalid for more details.
|
klao@959
|
87 |
Node(Invalid) { }
|
klao@959
|
88 |
/// Equality operator
|
klao@959
|
89 |
|
klao@959
|
90 |
/// Two iterators are equal if and only if they point to the
|
klao@959
|
91 |
/// same object or both are invalid.
|
klao@959
|
92 |
bool operator==(Node) const { return true; }
|
klao@959
|
93 |
|
klao@959
|
94 |
/// Inequality operator
|
klao@959
|
95 |
|
klao@959
|
96 |
/// \sa operator==(Node n)
|
klao@959
|
97 |
///
|
klao@959
|
98 |
bool operator!=(Node) const { return true; }
|
klao@959
|
99 |
|
klao@959
|
100 |
///Comparison operator.
|
klao@959
|
101 |
|
klao@959
|
102 |
///This is a strict ordering between the nodes.
|
klao@959
|
103 |
///
|
klao@959
|
104 |
///This ordering can be different from the order in which NodeIt
|
klao@959
|
105 |
///goes through the nodes.
|
klao@959
|
106 |
///\todo Possibly we don't need it.
|
klao@959
|
107 |
bool operator<(Node) const { return true; }
|
klao@959
|
108 |
};
|
klao@959
|
109 |
|
klao@959
|
110 |
/// This iterator goes through each node.
|
klao@959
|
111 |
|
klao@959
|
112 |
/// This iterator goes through each node.
|
klao@959
|
113 |
/// Its usage is quite simple, for example you can count the number
|
klao@959
|
114 |
/// of nodes in graph \c g of type \c Graph like this:
|
klao@959
|
115 |
/// \code
|
klao@959
|
116 |
/// int count=0;
|
klao@959
|
117 |
/// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
|
klao@959
|
118 |
/// \endcode
|
klao@959
|
119 |
class NodeIt : public Node {
|
klao@959
|
120 |
public:
|
klao@959
|
121 |
/// Default constructor
|
klao@959
|
122 |
|
klao@959
|
123 |
/// @warning The default constructor sets the iterator
|
klao@959
|
124 |
/// to an undefined value.
|
klao@959
|
125 |
NodeIt() { }
|
klao@959
|
126 |
/// Copy constructor.
|
klao@959
|
127 |
|
klao@959
|
128 |
/// Copy constructor.
|
klao@959
|
129 |
///
|
klao@959
|
130 |
NodeIt(const NodeIt&) { }
|
klao@959
|
131 |
/// Invalid constructor \& conversion.
|
klao@959
|
132 |
|
klao@959
|
133 |
/// Initialize the iterator to be invalid.
|
klao@959
|
134 |
/// \sa Invalid for more details.
|
klao@959
|
135 |
NodeIt(Invalid) { }
|
klao@959
|
136 |
/// Sets the iterator to the first node.
|
klao@959
|
137 |
|
klao@959
|
138 |
/// Sets the iterator to the first node of \c g.
|
klao@959
|
139 |
///
|
klao@959
|
140 |
NodeIt(const StaticSymGraph& g) { }
|
klao@959
|
141 |
/// Node -> NodeIt conversion.
|
klao@959
|
142 |
|
klao@959
|
143 |
/// Sets the iterator to the node of \c g pointed by the trivial
|
klao@959
|
144 |
/// iterator n.
|
klao@959
|
145 |
/// This feature necessitates that each time we
|
klao@959
|
146 |
/// iterate the edge-set, the iteration order is the same.
|
klao@959
|
147 |
NodeIt(const StaticSymGraph& g, const Node& n) { }
|
klao@959
|
148 |
/// Next node.
|
klao@959
|
149 |
|
klao@959
|
150 |
/// Assign the iterator to the next node.
|
klao@959
|
151 |
///
|
klao@959
|
152 |
NodeIt& operator++() { return *this; }
|
klao@959
|
153 |
};
|
klao@959
|
154 |
|
klao@959
|
155 |
|
klao@959
|
156 |
/// The base type of the symmetric edge iterators.
|
klao@959
|
157 |
|
klao@959
|
158 |
/// The base type of the symmetric edge iterators.
|
klao@959
|
159 |
///
|
klao@959
|
160 |
class SymEdge {
|
klao@959
|
161 |
public:
|
klao@959
|
162 |
/// Default constructor
|
klao@959
|
163 |
|
klao@959
|
164 |
/// @warning The default constructor sets the iterator
|
klao@959
|
165 |
/// to an undefined value.
|
klao@959
|
166 |
SymEdge() { }
|
klao@959
|
167 |
/// Copy constructor.
|
klao@959
|
168 |
|
klao@959
|
169 |
/// Copy constructor.
|
klao@959
|
170 |
///
|
klao@959
|
171 |
SymEdge(const SymEdge&) { }
|
klao@959
|
172 |
/// Initialize the iterator to be invalid.
|
klao@959
|
173 |
|
klao@959
|
174 |
/// Initialize the iterator to be invalid.
|
klao@959
|
175 |
///
|
klao@959
|
176 |
SymEdge(Invalid) { }
|
klao@959
|
177 |
/// Equality operator
|
klao@959
|
178 |
|
klao@959
|
179 |
/// Two iterators are equal if and only if they point to the
|
klao@959
|
180 |
/// same object or both are invalid.
|
klao@959
|
181 |
bool operator==(SymEdge) const { return true; }
|
klao@959
|
182 |
/// Inequality operator
|
klao@959
|
183 |
|
klao@959
|
184 |
/// \sa operator==(Node n)
|
klao@959
|
185 |
///
|
klao@959
|
186 |
bool operator!=(SymEdge) const { return true; }
|
klao@959
|
187 |
///Comparison operator.
|
klao@959
|
188 |
|
klao@959
|
189 |
///This is a strict ordering between the nodes.
|
klao@959
|
190 |
///
|
klao@959
|
191 |
///This ordering can be different from the order in which NodeIt
|
klao@959
|
192 |
///goes through the nodes.
|
klao@959
|
193 |
///\todo Possibly we don't need it.
|
klao@959
|
194 |
bool operator<(SymEdge) const { return true; }
|
klao@959
|
195 |
};
|
klao@959
|
196 |
|
klao@959
|
197 |
|
klao@959
|
198 |
/// The base type of the edge iterators.
|
klao@959
|
199 |
|
klao@959
|
200 |
/// The base type of the edge iterators.
|
klao@959
|
201 |
///
|
klao@959
|
202 |
class Edge : public SymEdge {
|
klao@959
|
203 |
public:
|
klao@959
|
204 |
/// Default constructor
|
klao@959
|
205 |
|
klao@959
|
206 |
/// @warning The default constructor sets the iterator
|
klao@959
|
207 |
/// to an undefined value.
|
klao@959
|
208 |
Edge() { }
|
klao@959
|
209 |
/// Copy constructor.
|
klao@959
|
210 |
|
klao@959
|
211 |
/// Copy constructor.
|
klao@959
|
212 |
///
|
klao@959
|
213 |
Edge(const Edge&) { }
|
klao@959
|
214 |
/// Initialize the iterator to be invalid.
|
klao@959
|
215 |
|
klao@959
|
216 |
/// Initialize the iterator to be invalid.
|
klao@959
|
217 |
///
|
klao@959
|
218 |
Edge(Invalid) { }
|
klao@959
|
219 |
/// Equality operator
|
klao@959
|
220 |
|
klao@959
|
221 |
/// Two iterators are equal if and only if they point to the
|
klao@959
|
222 |
/// same object or both are invalid.
|
klao@959
|
223 |
bool operator==(Edge) const { return true; }
|
klao@959
|
224 |
/// Inequality operator
|
klao@959
|
225 |
|
klao@959
|
226 |
/// \sa operator==(Node n)
|
klao@959
|
227 |
///
|
klao@959
|
228 |
bool operator!=(Edge) const { return true; }
|
klao@959
|
229 |
///Comparison operator.
|
klao@959
|
230 |
|
klao@959
|
231 |
///This is a strict ordering between the nodes.
|
klao@959
|
232 |
///
|
klao@959
|
233 |
///This ordering can be different from the order in which NodeIt
|
klao@959
|
234 |
///goes through the nodes.
|
klao@959
|
235 |
///\todo Possibly we don't need it.
|
klao@959
|
236 |
bool operator<(Edge) const { return true; }
|
klao@959
|
237 |
};
|
klao@959
|
238 |
|
klao@959
|
239 |
/// This iterator goes trough the outgoing edges of a node.
|
klao@959
|
240 |
|
klao@959
|
241 |
/// This iterator goes trough the \e outgoing edges of a certain node
|
klao@959
|
242 |
/// of a graph.
|
klao@959
|
243 |
/// Its usage is quite simple, for example you can count the number
|
klao@959
|
244 |
/// of outgoing edges of a node \c n
|
klao@959
|
245 |
/// in graph \c g of type \c Graph as follows.
|
klao@959
|
246 |
/// \code
|
klao@959
|
247 |
/// int count=0;
|
klao@959
|
248 |
/// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
klao@959
|
249 |
/// \endcode
|
klao@959
|
250 |
|
klao@959
|
251 |
class OutEdgeIt : public Edge {
|
klao@959
|
252 |
public:
|
klao@959
|
253 |
/// Default constructor
|
klao@959
|
254 |
|
klao@959
|
255 |
/// @warning The default constructor sets the iterator
|
klao@959
|
256 |
/// to an undefined value.
|
klao@959
|
257 |
OutEdgeIt() { }
|
klao@959
|
258 |
/// Copy constructor.
|
klao@959
|
259 |
|
klao@959
|
260 |
/// Copy constructor.
|
klao@959
|
261 |
///
|
klao@959
|
262 |
OutEdgeIt(const OutEdgeIt&) { }
|
klao@959
|
263 |
/// Initialize the iterator to be invalid.
|
klao@959
|
264 |
|
klao@959
|
265 |
/// Initialize the iterator to be invalid.
|
klao@959
|
266 |
///
|
klao@959
|
267 |
OutEdgeIt(Invalid) { }
|
klao@959
|
268 |
/// This constructor sets the iterator to first outgoing edge.
|
klao@959
|
269 |
|
klao@959
|
270 |
/// This constructor set the iterator to the first outgoing edge of
|
klao@959
|
271 |
/// node
|
klao@959
|
272 |
///@param n the node
|
klao@959
|
273 |
///@param g the graph
|
klao@959
|
274 |
OutEdgeIt(const StaticSymGraph& g, const Node& n) { }
|
klao@959
|
275 |
/// Edge -> OutEdgeIt conversion
|
klao@959
|
276 |
|
klao@959
|
277 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
klao@959
|
278 |
/// This feature necessitates that each time we
|
klao@959
|
279 |
/// iterate the edge-set, the iteration order is the same.
|
klao@959
|
280 |
OutEdgeIt(const StaticSymGraph& g, const Edge& e) { }
|
klao@959
|
281 |
///Next outgoing edge
|
klao@959
|
282 |
|
klao@959
|
283 |
/// Assign the iterator to the next
|
klao@959
|
284 |
/// outgoing edge of the corresponding node.
|
klao@959
|
285 |
OutEdgeIt& operator++() { return *this; }
|
klao@959
|
286 |
};
|
klao@959
|
287 |
|
klao@959
|
288 |
/// This iterator goes trough the incoming edges of a node.
|
klao@959
|
289 |
|
klao@959
|
290 |
/// This iterator goes trough the \e incoming edges of a certain node
|
klao@959
|
291 |
/// of a graph.
|
klao@959
|
292 |
/// Its usage is quite simple, for example you can count the number
|
klao@959
|
293 |
/// of outgoing edges of a node \c n
|
klao@959
|
294 |
/// in graph \c g of type \c Graph as follows.
|
klao@959
|
295 |
/// \code
|
klao@959
|
296 |
/// int count=0;
|
klao@959
|
297 |
/// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
klao@959
|
298 |
/// \endcode
|
klao@959
|
299 |
|
klao@959
|
300 |
class InEdgeIt : public Edge {
|
klao@959
|
301 |
public:
|
klao@959
|
302 |
/// Default constructor
|
klao@959
|
303 |
|
klao@959
|
304 |
/// @warning The default constructor sets the iterator
|
klao@959
|
305 |
/// to an undefined value.
|
klao@959
|
306 |
InEdgeIt() { }
|
klao@959
|
307 |
/// Copy constructor.
|
klao@959
|
308 |
|
klao@959
|
309 |
/// Copy constructor.
|
klao@959
|
310 |
///
|
klao@959
|
311 |
InEdgeIt(const InEdgeIt&) { }
|
klao@959
|
312 |
/// Initialize the iterator to be invalid.
|
klao@959
|
313 |
|
klao@959
|
314 |
/// Initialize the iterator to be invalid.
|
klao@959
|
315 |
///
|
klao@959
|
316 |
InEdgeIt(Invalid) { }
|
klao@959
|
317 |
/// This constructor sets the iterator to first incoming edge.
|
klao@959
|
318 |
|
klao@959
|
319 |
/// This constructor set the iterator to the first incoming edge of
|
klao@959
|
320 |
/// node
|
klao@959
|
321 |
///@param n the node
|
klao@959
|
322 |
///@param g the graph
|
klao@959
|
323 |
InEdgeIt(const StaticSymGraph& g, const Node& n) { }
|
klao@959
|
324 |
/// Edge -> InEdgeIt conversion
|
klao@959
|
325 |
|
klao@959
|
326 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
klao@959
|
327 |
/// This feature necessitates that each time we
|
klao@959
|
328 |
/// iterate the edge-set, the iteration order is the same.
|
klao@959
|
329 |
InEdgeIt(const StaticSymGraph& g, const Edge& n) { }
|
klao@959
|
330 |
/// Next incoming edge
|
klao@959
|
331 |
|
klao@959
|
332 |
/// Assign the iterator to the next inedge of the corresponding node.
|
klao@959
|
333 |
///
|
klao@959
|
334 |
InEdgeIt& operator++() { return *this; }
|
klao@959
|
335 |
};
|
klao@959
|
336 |
/// This iterator goes through each symmetric edge.
|
klao@959
|
337 |
|
klao@959
|
338 |
/// This iterator goes through each symmetric edge of a graph.
|
klao@959
|
339 |
/// Its usage is quite simple, for example you can count the number
|
klao@959
|
340 |
/// of symmetric edges in a graph \c g of type \c Graph as follows:
|
klao@959
|
341 |
/// \code
|
klao@959
|
342 |
/// int count=0;
|
klao@959
|
343 |
/// for(Graph::SymEdgeIt e(g); e!=INVALID; ++e) ++count;
|
klao@959
|
344 |
/// \endcode
|
klao@959
|
345 |
class SymEdgeIt : public SymEdge {
|
klao@959
|
346 |
public:
|
klao@959
|
347 |
/// Default constructor
|
klao@959
|
348 |
|
klao@959
|
349 |
/// @warning The default constructor sets the iterator
|
klao@959
|
350 |
/// to an undefined value.
|
klao@959
|
351 |
SymEdgeIt() { }
|
klao@959
|
352 |
/// Copy constructor.
|
klao@959
|
353 |
|
klao@959
|
354 |
/// Copy constructor.
|
klao@959
|
355 |
///
|
klao@959
|
356 |
SymEdgeIt(const SymEdgeIt&) { }
|
klao@959
|
357 |
/// Initialize the iterator to be invalid.
|
klao@959
|
358 |
|
klao@959
|
359 |
/// Initialize the iterator to be invalid.
|
klao@959
|
360 |
///
|
klao@959
|
361 |
SymEdgeIt(Invalid) { }
|
klao@959
|
362 |
/// This constructor sets the iterator to first edge.
|
klao@959
|
363 |
|
klao@959
|
364 |
/// This constructor set the iterator to the first edge of
|
klao@959
|
365 |
/// node
|
klao@959
|
366 |
///@param g the graph
|
klao@959
|
367 |
SymEdgeIt(const StaticSymGraph& g) { }
|
klao@959
|
368 |
/// Edge -> EdgeIt conversion
|
klao@959
|
369 |
|
klao@959
|
370 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
klao@959
|
371 |
/// This feature necessitates that each time we
|
klao@959
|
372 |
/// iterate the edge-set, the iteration order is the same.
|
klao@959
|
373 |
SymEdgeIt(const StaticSymGraph&, const SymEdge&) { }
|
klao@959
|
374 |
///Next edge
|
klao@959
|
375 |
|
klao@959
|
376 |
/// Assign the iterator to the next
|
klao@959
|
377 |
/// edge of the corresponding node.
|
klao@959
|
378 |
SymEdgeIt& operator++() { return *this; }
|
klao@959
|
379 |
};
|
klao@959
|
380 |
/// This iterator goes through each edge.
|
klao@959
|
381 |
|
klao@959
|
382 |
/// This iterator goes through each edge of a graph.
|
klao@959
|
383 |
/// Its usage is quite simple, for example you can count the number
|
klao@959
|
384 |
/// of edges in a graph \c g of type \c Graph as follows:
|
klao@959
|
385 |
/// \code
|
klao@959
|
386 |
/// int count=0;
|
klao@959
|
387 |
/// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
|
klao@959
|
388 |
/// \endcode
|
klao@959
|
389 |
class EdgeIt : public Edge {
|
klao@959
|
390 |
public:
|
klao@959
|
391 |
/// Default constructor
|
klao@959
|
392 |
|
klao@959
|
393 |
/// @warning The default constructor sets the iterator
|
klao@959
|
394 |
/// to an undefined value.
|
klao@959
|
395 |
EdgeIt() { }
|
klao@959
|
396 |
/// Copy constructor.
|
klao@959
|
397 |
|
klao@959
|
398 |
/// Copy constructor.
|
klao@959
|
399 |
///
|
klao@959
|
400 |
EdgeIt(const EdgeIt&) { }
|
klao@959
|
401 |
/// Initialize the iterator to be invalid.
|
klao@959
|
402 |
|
klao@959
|
403 |
/// Initialize the iterator to be invalid.
|
klao@959
|
404 |
///
|
klao@959
|
405 |
EdgeIt(Invalid) { }
|
klao@959
|
406 |
/// This constructor sets the iterator to first edge.
|
klao@959
|
407 |
|
klao@959
|
408 |
/// This constructor set the iterator to the first edge of
|
klao@959
|
409 |
/// node
|
klao@959
|
410 |
///@param g the graph
|
klao@959
|
411 |
EdgeIt(const StaticSymGraph& g) { }
|
klao@959
|
412 |
/// Edge -> EdgeIt conversion
|
klao@959
|
413 |
|
klao@959
|
414 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
klao@959
|
415 |
/// This feature necessitates that each time we
|
klao@959
|
416 |
/// iterate the edge-set, the iteration order is the same.
|
klao@959
|
417 |
EdgeIt(const StaticSymGraph&, const Edge&) { }
|
klao@959
|
418 |
///Next edge
|
klao@959
|
419 |
|
klao@959
|
420 |
/// Assign the iterator to the next
|
klao@959
|
421 |
/// edge of the corresponding node.
|
klao@959
|
422 |
EdgeIt& operator++() { return *this; }
|
klao@959
|
423 |
};
|
klao@959
|
424 |
|
klao@959
|
425 |
/// First node of the graph.
|
klao@959
|
426 |
|
klao@959
|
427 |
/// \retval i the first node.
|
klao@959
|
428 |
/// \return the first node.
|
klao@959
|
429 |
///
|
klao@959
|
430 |
NodeIt& first(NodeIt& i) const { return i; }
|
klao@959
|
431 |
|
klao@959
|
432 |
/// The first incoming edge.
|
klao@959
|
433 |
|
klao@959
|
434 |
/// The first incoming edge.
|
klao@959
|
435 |
///
|
klao@959
|
436 |
InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
|
klao@959
|
437 |
/// The first outgoing edge.
|
klao@959
|
438 |
|
klao@959
|
439 |
/// The first outgoing edge.
|
klao@959
|
440 |
///
|
klao@959
|
441 |
OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
|
klao@959
|
442 |
/// The first edge of the Graph.
|
klao@959
|
443 |
|
klao@959
|
444 |
/// The first edge of the Graph.
|
klao@959
|
445 |
///
|
klao@959
|
446 |
EdgeIt& first(EdgeIt& i) const { return i; }
|
klao@959
|
447 |
/// The first symmetric edge of the Graph.
|
klao@959
|
448 |
|
klao@959
|
449 |
/// The first symmetric edge of the Graph.
|
klao@959
|
450 |
///
|
klao@959
|
451 |
SymEdgeIt& first(SymEdgeIt& i) const { return i; }
|
klao@959
|
452 |
|
klao@959
|
453 |
///Gives back the head node of an edge.
|
klao@959
|
454 |
|
klao@959
|
455 |
///Gives back the head node of an edge.
|
klao@959
|
456 |
///
|
klao@959
|
457 |
Node head(Edge) const { return INVALID; }
|
klao@959
|
458 |
///Gives back the tail node of an edge.
|
klao@959
|
459 |
|
klao@959
|
460 |
///Gives back the tail node of an edge.
|
klao@959
|
461 |
///
|
klao@959
|
462 |
Node tail(Edge) const { return INVALID; }
|
klao@959
|
463 |
|
klao@959
|
464 |
///Gives back the first node of an symmetric edge.
|
klao@959
|
465 |
|
klao@959
|
466 |
///Gives back the first node of an symmetric edge.
|
klao@959
|
467 |
///
|
klao@959
|
468 |
Node head(SymEdge) const { return INVALID; }
|
klao@959
|
469 |
///Gives back the second node of an symmetric edge.
|
klao@959
|
470 |
|
klao@959
|
471 |
///Gives back the second node of an symmetric edge.
|
klao@959
|
472 |
///
|
klao@959
|
473 |
Node tail(SymEdge) const { return INVALID; }
|
klao@959
|
474 |
///Gives back the \e id of a node.
|
klao@959
|
475 |
|
klao@959
|
476 |
///\warning Not all graph structures provide this feature.
|
klao@959
|
477 |
///
|
klao@959
|
478 |
///\todo Should each graph provide \c id?
|
klao@959
|
479 |
int id(const Node&) const { return 0; }
|
klao@959
|
480 |
///Gives back the \e id of an edge.
|
klao@959
|
481 |
|
klao@959
|
482 |
///\warning Not all graph structures provide this feature.
|
klao@959
|
483 |
///
|
klao@959
|
484 |
///\todo Should each graph provide \c id?
|
klao@959
|
485 |
int id(const Edge&) const { return 0; }
|
klao@959
|
486 |
|
klao@959
|
487 |
///\warning Not all graph structures provide this feature.
|
klao@959
|
488 |
///
|
klao@959
|
489 |
///\todo Should each graph provide \c id?
|
klao@959
|
490 |
int id(const SymEdge&) const { return 0; }
|
klao@959
|
491 |
|
klao@959
|
492 |
///\e
|
klao@959
|
493 |
|
klao@959
|
494 |
///\todo Should it be in the concept?
|
klao@959
|
495 |
///
|
klao@959
|
496 |
int nodeNum() const { return 0; }
|
klao@959
|
497 |
///\e
|
klao@959
|
498 |
|
klao@959
|
499 |
///\todo Should it be in the concept?
|
klao@959
|
500 |
///
|
klao@959
|
501 |
int edgeNum() const { return 0; }
|
klao@959
|
502 |
|
klao@959
|
503 |
///\todo Should it be in the concept?
|
klao@959
|
504 |
///
|
klao@959
|
505 |
int symEdgeNum() const { return 0; }
|
klao@959
|
506 |
|
klao@959
|
507 |
|
klao@959
|
508 |
/// Gives back the forward directed edge of the symmetric edge.
|
klao@959
|
509 |
Edge forward(SymEdge) const {return INVALID;}
|
klao@959
|
510 |
|
klao@959
|
511 |
/// Gives back the backward directed edge of the symmetric edge.
|
klao@959
|
512 |
Edge backward(SymEdge) const {return INVALID;};
|
klao@959
|
513 |
|
klao@959
|
514 |
/// Gives back the opposite of the edge.
|
klao@959
|
515 |
Edge opposite(Edge) const {return INVALID;}
|
klao@959
|
516 |
|
klao@959
|
517 |
///Reference map of the nodes to type \c T.
|
klao@959
|
518 |
/// \ingroup concept
|
klao@959
|
519 |
///Reference map of the nodes to type \c T.
|
klao@959
|
520 |
/// \sa Reference
|
klao@959
|
521 |
/// \warning Making maps that can handle bool type (NodeMap<bool>)
|
klao@959
|
522 |
/// needs some extra attention!
|
klao@959
|
523 |
template<class T> class NodeMap : public ReferenceMap< Node, T >
|
klao@959
|
524 |
{
|
klao@959
|
525 |
public:
|
klao@959
|
526 |
|
klao@959
|
527 |
///\e
|
klao@959
|
528 |
NodeMap(const StaticSymGraph&) { }
|
klao@959
|
529 |
///\e
|
klao@959
|
530 |
NodeMap(const StaticSymGraph&, T) { }
|
klao@959
|
531 |
|
klao@959
|
532 |
///Copy constructor
|
klao@959
|
533 |
template<typename TT> NodeMap(const NodeMap<TT>&) { }
|
klao@959
|
534 |
///Assignment operator
|
klao@959
|
535 |
template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
|
klao@959
|
536 |
{ return *this; }
|
klao@959
|
537 |
};
|
klao@959
|
538 |
|
klao@959
|
539 |
///Reference map of the edges to type \c T.
|
klao@959
|
540 |
|
klao@959
|
541 |
/// \ingroup concept
|
klao@959
|
542 |
///Reference map of the edges to type \c T.
|
klao@959
|
543 |
/// \sa Reference
|
klao@959
|
544 |
/// \warning Making maps that can handle bool type (EdgeMap<bool>)
|
klao@959
|
545 |
/// needs some extra attention!
|
klao@959
|
546 |
template<class T> class EdgeMap
|
klao@959
|
547 |
: public ReferenceMap<Edge,T>
|
klao@959
|
548 |
{
|
klao@959
|
549 |
public:
|
klao@959
|
550 |
|
klao@959
|
551 |
///\e
|
klao@959
|
552 |
EdgeMap(const StaticSymGraph&) { }
|
klao@959
|
553 |
///\e
|
klao@959
|
554 |
EdgeMap(const StaticSymGraph&, T) { }
|
klao@959
|
555 |
|
klao@959
|
556 |
///Copy constructor
|
klao@959
|
557 |
template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
|
klao@959
|
558 |
///Assignment operator
|
klao@959
|
559 |
template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
|
klao@959
|
560 |
{ return *this; }
|
klao@959
|
561 |
};
|
klao@959
|
562 |
|
klao@959
|
563 |
///Reference map of the edges to type \c T.
|
klao@959
|
564 |
|
klao@959
|
565 |
/// \ingroup concept
|
klao@959
|
566 |
///Reference map of the symmetric edges to type \c T.
|
klao@959
|
567 |
/// \sa Reference
|
klao@959
|
568 |
/// \warning Making maps that can handle bool type (EdgeMap<bool>)
|
klao@959
|
569 |
/// needs some extra attention!
|
klao@959
|
570 |
template<class T> class SymEdgeMap
|
klao@959
|
571 |
: public ReferenceMap<SymEdge,T>
|
klao@959
|
572 |
{
|
klao@959
|
573 |
public:
|
klao@959
|
574 |
|
klao@959
|
575 |
///\e
|
klao@959
|
576 |
SymEdgeMap(const StaticSymGraph&) { }
|
klao@959
|
577 |
///\e
|
klao@959
|
578 |
SymEdgeMap(const StaticSymGraph&, T) { }
|
klao@959
|
579 |
|
klao@959
|
580 |
///Copy constructor
|
klao@959
|
581 |
template<typename TT> SymEdgeMap(const SymEdgeMap<TT>&) { }
|
klao@959
|
582 |
///Assignment operator
|
klao@959
|
583 |
template<typename TT> SymEdgeMap &operator=(const SymEdgeMap<TT>&)
|
klao@959
|
584 |
{ return *this; }
|
klao@959
|
585 |
};
|
klao@959
|
586 |
};
|
klao@959
|
587 |
|
klao@959
|
588 |
|
klao@959
|
589 |
|
klao@959
|
590 |
/// An empty non-static graph class.
|
klao@959
|
591 |
|
klao@959
|
592 |
/// This class provides everything that \ref StaticGraph
|
klao@959
|
593 |
/// with additional functionality which enables to build a
|
klao@959
|
594 |
/// graph from scratch.
|
klao@959
|
595 |
class ExtendableSymGraph : public StaticSymGraph
|
klao@959
|
596 |
{
|
klao@959
|
597 |
public:
|
klao@959
|
598 |
/// Defalult constructor.
|
klao@959
|
599 |
|
klao@959
|
600 |
/// Defalult constructor.
|
klao@959
|
601 |
///
|
klao@959
|
602 |
ExtendableSymGraph() { }
|
klao@959
|
603 |
///Add a new node to the graph.
|
klao@959
|
604 |
|
klao@959
|
605 |
/// \return the new node.
|
klao@959
|
606 |
///
|
klao@959
|
607 |
Node addNode() { return INVALID; }
|
klao@959
|
608 |
///Add a new edge to the graph.
|
klao@959
|
609 |
|
klao@959
|
610 |
///Add a new symmetric edge to the graph with tail node \c t
|
klao@959
|
611 |
///and head node \c h.
|
klao@959
|
612 |
///\return the new edge.
|
klao@959
|
613 |
SymEdge addEdge(Node h, Node t) { return INVALID; }
|
klao@959
|
614 |
|
klao@959
|
615 |
/// Resets the graph.
|
klao@959
|
616 |
|
klao@959
|
617 |
/// This function deletes all edges and nodes of the graph.
|
klao@959
|
618 |
/// It also frees the memory allocated to store them.
|
klao@959
|
619 |
/// \todo It might belong to \ref ErasableGraph.
|
klao@959
|
620 |
void clear() { }
|
klao@959
|
621 |
};
|
klao@959
|
622 |
|
klao@959
|
623 |
/// An empty erasable graph class.
|
klao@959
|
624 |
|
klao@959
|
625 |
/// This class is an extension of \ref ExtendableGraph. It also makes it
|
klao@959
|
626 |
/// possible to erase edges or nodes.
|
klao@959
|
627 |
class ErasableSymGraph : public ExtendableSymGraph
|
klao@959
|
628 |
{
|
klao@959
|
629 |
public:
|
klao@959
|
630 |
/// Defalult constructor.
|
klao@959
|
631 |
|
klao@959
|
632 |
/// Defalult constructor.
|
klao@959
|
633 |
///
|
klao@959
|
634 |
ErasableSymGraph() { }
|
klao@959
|
635 |
/// Deletes a node.
|
klao@959
|
636 |
|
klao@959
|
637 |
/// Deletes node \c n node.
|
klao@959
|
638 |
///
|
klao@959
|
639 |
void erase(Node n) { }
|
klao@959
|
640 |
/// Deletes an edge.
|
klao@959
|
641 |
|
klao@959
|
642 |
/// Deletes edge \c e edge.
|
klao@959
|
643 |
///
|
klao@959
|
644 |
void erase(SymEdge e) { }
|
klao@959
|
645 |
};
|
klao@959
|
646 |
|
klao@959
|
647 |
// @}
|
klao@959
|
648 |
} //namespace concept
|
klao@959
|
649 |
} //namespace lemon
|
klao@959
|
650 |
|
klao@959
|
651 |
|
klao@959
|
652 |
|
klao@959
|
653 |
#endif // LEMON_CONCEPT_GRAPH_H
|