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