alpar@209
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
deba@57
|
2 |
*
|
alpar@209
|
3 |
* This file is a part of LEMON, a generic C++ optimization library.
|
deba@57
|
4 |
*
|
alpar@1092
|
5 |
* Copyright (C) 2003-2013
|
deba@57
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
deba@57
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
deba@57
|
8 |
*
|
deba@57
|
9 |
* Permission to use, modify and distribute this software is granted
|
deba@57
|
10 |
* provided that this copyright notice appears in all copies. For
|
deba@57
|
11 |
* precise terms see the accompanying LICENSE file.
|
deba@57
|
12 |
*
|
deba@57
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
deba@57
|
14 |
* express or implied, and with no claim as to its suitability for any
|
deba@57
|
15 |
* purpose.
|
deba@57
|
16 |
*
|
deba@57
|
17 |
*/
|
deba@57
|
18 |
|
deba@57
|
19 |
///\ingroup graph_concepts
|
deba@57
|
20 |
///\file
|
kpeter@734
|
21 |
///\brief The concept of undirected graphs.
|
deba@57
|
22 |
|
deba@529
|
23 |
#ifndef LEMON_CONCEPTS_GRAPH_H
|
deba@529
|
24 |
#define LEMON_CONCEPTS_GRAPH_H
|
deba@57
|
25 |
|
deba@57
|
26 |
#include <lemon/concepts/graph_components.h>
|
kpeter@734
|
27 |
#include <lemon/concepts/maps.h>
|
kpeter@734
|
28 |
#include <lemon/concept_check.h>
|
deba@220
|
29 |
#include <lemon/core.h>
|
ggab90@1130
|
30 |
#include <lemon/bits/stl_iterators.h>
|
deba@57
|
31 |
|
deba@57
|
32 |
namespace lemon {
|
deba@57
|
33 |
namespace concepts {
|
deba@57
|
34 |
|
deba@57
|
35 |
/// \ingroup graph_concepts
|
deba@57
|
36 |
///
|
kpeter@734
|
37 |
/// \brief Class describing the concept of undirected graphs.
|
deba@57
|
38 |
///
|
kpeter@734
|
39 |
/// This class describes the common interface of all undirected
|
kpeter@734
|
40 |
/// graphs.
|
deba@57
|
41 |
///
|
kpeter@734
|
42 |
/// Like all concept classes, it only provides an interface
|
kpeter@734
|
43 |
/// without any sensible implementation. So any general algorithm for
|
kpeter@734
|
44 |
/// undirected graphs should compile with this class, but it will not
|
deba@57
|
45 |
/// run properly, of course.
|
kpeter@734
|
46 |
/// An actual graph implementation like \ref ListGraph or
|
alpar@877
|
47 |
/// \ref SmartGraph may have additional functionality.
|
deba@57
|
48 |
///
|
kpeter@734
|
49 |
/// The undirected graphs also fulfill the concept of \ref Digraph
|
kpeter@734
|
50 |
/// "directed graphs", since each edge can also be regarded as two
|
kpeter@734
|
51 |
/// oppositely directed arcs.
|
kpeter@734
|
52 |
/// Undirected graphs provide an Edge type for the undirected edges and
|
kpeter@734
|
53 |
/// an Arc type for the directed arcs. The Arc type is convertible to
|
kpeter@734
|
54 |
/// Edge or inherited from it, i.e. the corresponding edge can be
|
kpeter@734
|
55 |
/// obtained from an arc.
|
kpeter@734
|
56 |
/// EdgeIt and EdgeMap classes can be used for the edges, while ArcIt
|
kpeter@734
|
57 |
/// and ArcMap classes can be used for the arcs (just like in digraphs).
|
kpeter@734
|
58 |
/// Both InArcIt and OutArcIt iterates on the same edges but with
|
kpeter@734
|
59 |
/// opposite direction. IncEdgeIt also iterates on the same edges
|
kpeter@734
|
60 |
/// as OutArcIt and InArcIt, but it is not convertible to Arc,
|
kpeter@734
|
61 |
/// only to Edge.
|
deba@57
|
62 |
///
|
kpeter@734
|
63 |
/// In LEMON, each undirected edge has an inherent orientation.
|
kpeter@734
|
64 |
/// Thus it can defined if an arc is forward or backward oriented in
|
kpeter@734
|
65 |
/// an undirected graph with respect to this default oriantation of
|
kpeter@734
|
66 |
/// the represented edge.
|
kpeter@734
|
67 |
/// With the direction() and direct() functions the direction
|
kpeter@734
|
68 |
/// of an arc can be obtained and set, respectively.
|
deba@57
|
69 |
///
|
kpeter@734
|
70 |
/// Only nodes and edges can be added to or removed from an undirected
|
kpeter@734
|
71 |
/// graph and the corresponding arcs are added or removed automatically.
|
kpeter@734
|
72 |
///
|
kpeter@734
|
73 |
/// \sa Digraph
|
deba@57
|
74 |
class Graph {
|
kpeter@734
|
75 |
private:
|
deba@1018
|
76 |
/// Graphs are \e not copy constructible. Use GraphCopy instead.
|
kpeter@734
|
77 |
Graph(const Graph&) {}
|
kpeter@734
|
78 |
/// \brief Assignment of a graph to another one is \e not allowed.
|
deba@1018
|
79 |
/// Use GraphCopy instead.
|
kpeter@734
|
80 |
void operator=(const Graph&) {}
|
kpeter@734
|
81 |
|
deba@57
|
82 |
public:
|
kpeter@734
|
83 |
/// Default constructor.
|
kpeter@734
|
84 |
Graph() {}
|
kpeter@734
|
85 |
|
kpeter@734
|
86 |
/// \brief Undirected graphs should be tagged with \c UndirectedTag.
|
deba@57
|
87 |
///
|
kpeter@734
|
88 |
/// Undirected graphs should be tagged with \c UndirectedTag.
|
alpar@877
|
89 |
///
|
kpeter@734
|
90 |
/// This tag helps the \c enable_if technics to make compile time
|
alpar@209
|
91 |
/// specializations for undirected graphs.
|
deba@57
|
92 |
typedef True UndirectedTag;
|
deba@57
|
93 |
|
kpeter@734
|
94 |
/// The node type of the graph
|
kpeter@734
|
95 |
|
kpeter@734
|
96 |
/// This class identifies a node of the graph. It also serves
|
kpeter@734
|
97 |
/// as a base class of the node iterators,
|
kpeter@734
|
98 |
/// thus they convert to this type.
|
deba@57
|
99 |
class Node {
|
deba@57
|
100 |
public:
|
deba@57
|
101 |
/// Default constructor
|
deba@57
|
102 |
|
kpeter@734
|
103 |
/// Default constructor.
|
kpeter@734
|
104 |
/// \warning It sets the object to an undefined value.
|
deba@57
|
105 |
Node() { }
|
deba@57
|
106 |
/// Copy constructor.
|
deba@57
|
107 |
|
deba@57
|
108 |
/// Copy constructor.
|
deba@57
|
109 |
///
|
deba@57
|
110 |
Node(const Node&) { }
|
alpar@1210
|
111 |
/// Assignment operator
|
alpar@1210
|
112 |
|
alpar@1210
|
113 |
/// Assignment operator.
|
alpar@1210
|
114 |
///
|
alpar@1210
|
115 |
const Node &operator=(const Node&) { return *this; }
|
deba@57
|
116 |
|
kpeter@734
|
117 |
/// %Invalid constructor \& conversion.
|
deba@57
|
118 |
|
kpeter@734
|
119 |
/// Initializes the object to be invalid.
|
deba@57
|
120 |
/// \sa Invalid for more details.
|
deba@57
|
121 |
Node(Invalid) { }
|
deba@57
|
122 |
/// Equality operator
|
deba@57
|
123 |
|
kpeter@734
|
124 |
/// Equality operator.
|
kpeter@734
|
125 |
///
|
deba@57
|
126 |
/// Two iterators are equal if and only if they point to the
|
kpeter@734
|
127 |
/// same object or both are \c INVALID.
|
deba@57
|
128 |
bool operator==(Node) const { return true; }
|
deba@57
|
129 |
|
deba@57
|
130 |
/// Inequality operator
|
alpar@209
|
131 |
|
kpeter@734
|
132 |
/// Inequality operator.
|
deba@57
|
133 |
bool operator!=(Node) const { return true; }
|
deba@57
|
134 |
|
alpar@209
|
135 |
/// Artificial ordering operator.
|
alpar@209
|
136 |
|
kpeter@734
|
137 |
/// Artificial ordering operator.
|
alpar@209
|
138 |
///
|
kpeter@734
|
139 |
/// \note This operator only has to define some strict ordering of
|
alpar@209
|
140 |
/// the items; this order has nothing to do with the iteration
|
alpar@209
|
141 |
/// ordering of the items.
|
alpar@209
|
142 |
bool operator<(Node) const { return false; }
|
deba@57
|
143 |
|
deba@57
|
144 |
};
|
alpar@209
|
145 |
|
kpeter@734
|
146 |
/// Iterator class for the nodes.
|
deba@57
|
147 |
|
kpeter@734
|
148 |
/// This iterator goes through each node of the graph.
|
kpeter@786
|
149 |
/// Its usage is quite simple, for example, you can count the number
|
kpeter@734
|
150 |
/// of nodes in a graph \c g of type \c %Graph like this:
|
deba@57
|
151 |
///\code
|
deba@57
|
152 |
/// int count=0;
|
deba@57
|
153 |
/// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
|
deba@57
|
154 |
///\endcode
|
deba@57
|
155 |
class NodeIt : public Node {
|
deba@57
|
156 |
public:
|
deba@57
|
157 |
/// Default constructor
|
deba@57
|
158 |
|
kpeter@734
|
159 |
/// Default constructor.
|
kpeter@734
|
160 |
/// \warning It sets the iterator to an undefined value.
|
deba@57
|
161 |
NodeIt() { }
|
deba@57
|
162 |
/// Copy constructor.
|
alpar@209
|
163 |
|
deba@57
|
164 |
/// Copy constructor.
|
deba@57
|
165 |
///
|
deba@57
|
166 |
NodeIt(const NodeIt& n) : Node(n) { }
|
alpar@1210
|
167 |
/// Assignment operator
|
alpar@1210
|
168 |
|
alpar@1210
|
169 |
/// Assignment operator.
|
alpar@1210
|
170 |
///
|
alpar@1210
|
171 |
const NodeIt &operator=(const NodeIt&) { return *this; }
|
alpar@1210
|
172 |
|
kpeter@734
|
173 |
/// %Invalid constructor \& conversion.
|
deba@57
|
174 |
|
kpeter@734
|
175 |
/// Initializes the iterator to be invalid.
|
deba@57
|
176 |
/// \sa Invalid for more details.
|
deba@57
|
177 |
NodeIt(Invalid) { }
|
deba@57
|
178 |
/// Sets the iterator to the first node.
|
deba@57
|
179 |
|
kpeter@734
|
180 |
/// Sets the iterator to the first node of the given digraph.
|
deba@57
|
181 |
///
|
kpeter@734
|
182 |
explicit NodeIt(const Graph&) { }
|
kpeter@734
|
183 |
/// Sets the iterator to the given node.
|
deba@57
|
184 |
|
kpeter@734
|
185 |
/// Sets the iterator to the given node of the given digraph.
|
kpeter@734
|
186 |
///
|
deba@57
|
187 |
NodeIt(const Graph&, const Node&) { }
|
deba@57
|
188 |
/// Next node.
|
deba@57
|
189 |
|
deba@57
|
190 |
/// Assign the iterator to the next node.
|
deba@57
|
191 |
///
|
deba@57
|
192 |
NodeIt& operator++() { return *this; }
|
deba@57
|
193 |
};
|
alpar@209
|
194 |
|
ggab90@1130
|
195 |
/// \brief Gets the collection of the nodes of the graph.
|
ggab90@1130
|
196 |
///
|
ggab90@1130
|
197 |
/// This function can be used for iterating on
|
ggab90@1130
|
198 |
/// the nodes of the graph. It returns a wrapped NodeIt, which looks
|
ggab90@1130
|
199 |
/// like an STL container (by having begin() and end())
|
ggab90@1130
|
200 |
/// which you can use in range-based for loops, STL algorithms, etc.
|
ggab90@1130
|
201 |
/// For example you can write:
|
ggab90@1130
|
202 |
///\code
|
ggab90@1130
|
203 |
/// ListGraph g;
|
ggab90@1130
|
204 |
/// for(auto v: g.nodes())
|
ggab90@1130
|
205 |
/// doSomething(v);
|
ggab90@1130
|
206 |
///
|
ggab90@1130
|
207 |
/// //Using an STL algorithm:
|
ggab90@1130
|
208 |
/// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
|
ggab90@1130
|
209 |
///\endcode
|
ggab90@1130
|
210 |
LemonRangeWrapper1<NodeIt, Graph> nodes() const {
|
ggab90@1130
|
211 |
return LemonRangeWrapper1<NodeIt, Graph>(*this);
|
ggab90@1130
|
212 |
}
|
ggab90@1130
|
213 |
|
alpar@209
|
214 |
|
kpeter@734
|
215 |
/// The edge type of the graph
|
deba@57
|
216 |
|
kpeter@734
|
217 |
/// This class identifies an edge of the graph. It also serves
|
kpeter@734
|
218 |
/// as a base class of the edge iterators,
|
kpeter@734
|
219 |
/// thus they will convert to this type.
|
deba@57
|
220 |
class Edge {
|
deba@57
|
221 |
public:
|
deba@57
|
222 |
/// Default constructor
|
deba@57
|
223 |
|
kpeter@734
|
224 |
/// Default constructor.
|
kpeter@734
|
225 |
/// \warning It sets the object to an undefined value.
|
deba@57
|
226 |
Edge() { }
|
deba@57
|
227 |
/// Copy constructor.
|
deba@57
|
228 |
|
deba@57
|
229 |
/// Copy constructor.
|
deba@57
|
230 |
///
|
deba@57
|
231 |
Edge(const Edge&) { }
|
alpar@1210
|
232 |
/// Assignment operator
|
alpar@1210
|
233 |
|
alpar@1210
|
234 |
/// Assignment operator.
|
alpar@1210
|
235 |
///
|
alpar@1210
|
236 |
const Edge &operator=(const Edge&) { return *this; }
|
alpar@1210
|
237 |
|
kpeter@734
|
238 |
/// %Invalid constructor \& conversion.
|
deba@57
|
239 |
|
kpeter@734
|
240 |
/// Initializes the object to be invalid.
|
kpeter@734
|
241 |
/// \sa Invalid for more details.
|
deba@57
|
242 |
Edge(Invalid) { }
|
deba@57
|
243 |
/// Equality operator
|
deba@57
|
244 |
|
kpeter@734
|
245 |
/// Equality operator.
|
kpeter@734
|
246 |
///
|
deba@57
|
247 |
/// Two iterators are equal if and only if they point to the
|
kpeter@734
|
248 |
/// same object or both are \c INVALID.
|
deba@57
|
249 |
bool operator==(Edge) const { return true; }
|
deba@57
|
250 |
/// Inequality operator
|
deba@57
|
251 |
|
kpeter@734
|
252 |
/// Inequality operator.
|
deba@57
|
253 |
bool operator!=(Edge) const { return true; }
|
deba@57
|
254 |
|
alpar@209
|
255 |
/// Artificial ordering operator.
|
alpar@209
|
256 |
|
kpeter@734
|
257 |
/// Artificial ordering operator.
|
alpar@209
|
258 |
///
|
kpeter@734
|
259 |
/// \note This operator only has to define some strict ordering of
|
kpeter@734
|
260 |
/// the edges; this order has nothing to do with the iteration
|
kpeter@734
|
261 |
/// ordering of the edges.
|
alpar@209
|
262 |
bool operator<(Edge) const { return false; }
|
deba@57
|
263 |
};
|
deba@57
|
264 |
|
kpeter@734
|
265 |
/// Iterator class for the edges.
|
deba@57
|
266 |
|
kpeter@734
|
267 |
/// This iterator goes through each edge of the graph.
|
kpeter@786
|
268 |
/// Its usage is quite simple, for example, you can count the number
|
kpeter@734
|
269 |
/// of edges in a graph \c g of type \c %Graph as follows:
|
deba@57
|
270 |
///\code
|
deba@57
|
271 |
/// int count=0;
|
deba@57
|
272 |
/// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
|
deba@57
|
273 |
///\endcode
|
deba@57
|
274 |
class EdgeIt : public Edge {
|
deba@57
|
275 |
public:
|
deba@57
|
276 |
/// Default constructor
|
deba@57
|
277 |
|
kpeter@734
|
278 |
/// Default constructor.
|
kpeter@734
|
279 |
/// \warning It sets the iterator to an undefined value.
|
deba@57
|
280 |
EdgeIt() { }
|
deba@57
|
281 |
/// Copy constructor.
|
deba@57
|
282 |
|
deba@57
|
283 |
/// Copy constructor.
|
deba@57
|
284 |
///
|
deba@57
|
285 |
EdgeIt(const EdgeIt& e) : Edge(e) { }
|
alpar@1210
|
286 |
/// Assignment operator
|
alpar@1210
|
287 |
|
alpar@1210
|
288 |
/// Assignment operator.
|
alpar@1210
|
289 |
///
|
alpar@1210
|
290 |
const EdgeIt &operator=(const EdgeIt&) { return *this; }
|
alpar@1210
|
291 |
|
kpeter@734
|
292 |
/// %Invalid constructor \& conversion.
|
deba@57
|
293 |
|
kpeter@734
|
294 |
/// Initializes the iterator to be invalid.
|
kpeter@734
|
295 |
/// \sa Invalid for more details.
|
kpeter@734
|
296 |
EdgeIt(Invalid) { }
|
kpeter@734
|
297 |
/// Sets the iterator to the first edge.
|
kpeter@734
|
298 |
|
kpeter@734
|
299 |
/// Sets the iterator to the first edge of the given graph.
|
deba@57
|
300 |
///
|
kpeter@734
|
301 |
explicit EdgeIt(const Graph&) { }
|
kpeter@734
|
302 |
/// Sets the iterator to the given edge.
|
alpar@209
|
303 |
|
kpeter@734
|
304 |
/// Sets the iterator to the given edge of the given graph.
|
kpeter@734
|
305 |
///
|
alpar@209
|
306 |
EdgeIt(const Graph&, const Edge&) { }
|
deba@57
|
307 |
/// Next edge
|
alpar@209
|
308 |
|
deba@57
|
309 |
/// Assign the iterator to the next edge.
|
kpeter@734
|
310 |
///
|
deba@57
|
311 |
EdgeIt& operator++() { return *this; }
|
deba@57
|
312 |
};
|
deba@57
|
313 |
|
ggab90@1130
|
314 |
/// \brief Gets the collection of the edges of the graph.
|
ggab90@1130
|
315 |
///
|
ggab90@1130
|
316 |
/// This function can be used for iterating on the
|
ggab90@1130
|
317 |
/// edges of the graph. It returns a wrapped
|
ggab90@1130
|
318 |
/// EdgeIt, which looks like an STL container
|
ggab90@1130
|
319 |
/// (by having begin() and end()) which you can use in range-based
|
ggab90@1130
|
320 |
/// for loops, STL algorithms, etc.
|
ggab90@1130
|
321 |
/// For example you can write:
|
ggab90@1130
|
322 |
///\code
|
ggab90@1130
|
323 |
/// ListGraph g;
|
ggab90@1130
|
324 |
/// for(auto e: g.edges())
|
ggab90@1130
|
325 |
/// doSomething(e);
|
ggab90@1130
|
326 |
///
|
ggab90@1130
|
327 |
/// //Using an STL algorithm:
|
ggab90@1130
|
328 |
/// copy(g.edges().begin(), g.edges().end(), vect.begin());
|
ggab90@1130
|
329 |
///\endcode
|
ggab90@1130
|
330 |
LemonRangeWrapper1<EdgeIt, Graph> edges() const {
|
ggab90@1130
|
331 |
return LemonRangeWrapper1<EdgeIt, Graph>(*this);
|
ggab90@1130
|
332 |
}
|
ggab90@1130
|
333 |
|
ggab90@1130
|
334 |
|
kpeter@734
|
335 |
/// Iterator class for the incident edges of a node.
|
kpeter@734
|
336 |
|
kpeter@734
|
337 |
/// This iterator goes trough the incident undirected edges
|
kpeter@734
|
338 |
/// of a certain node of a graph.
|
kpeter@786
|
339 |
/// Its usage is quite simple, for example, you can compute the
|
kpeter@734
|
340 |
/// degree (i.e. the number of incident edges) of a node \c n
|
kpeter@734
|
341 |
/// in a graph \c g of type \c %Graph as follows.
|
deba@57
|
342 |
///
|
deba@57
|
343 |
///\code
|
deba@57
|
344 |
/// int count=0;
|
deba@78
|
345 |
/// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
deba@57
|
346 |
///\endcode
|
kpeter@734
|
347 |
///
|
kpeter@734
|
348 |
/// \warning Loop edges will be iterated twice.
|
deba@78
|
349 |
class IncEdgeIt : public Edge {
|
deba@57
|
350 |
public:
|
deba@57
|
351 |
/// Default constructor
|
deba@57
|
352 |
|
kpeter@734
|
353 |
/// Default constructor.
|
kpeter@734
|
354 |
/// \warning It sets the iterator to an undefined value.
|
deba@78
|
355 |
IncEdgeIt() { }
|
deba@57
|
356 |
/// Copy constructor.
|
deba@57
|
357 |
|
deba@57
|
358 |
/// Copy constructor.
|
deba@57
|
359 |
///
|
deba@78
|
360 |
IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
|
alpar@1210
|
361 |
/// Assignment operator
|
alpar@1210
|
362 |
|
alpar@1210
|
363 |
/// Assignment operator.
|
alpar@1210
|
364 |
///
|
alpar@1210
|
365 |
const IncEdgeIt &operator=(const IncEdgeIt&) { return *this; }
|
alpar@1210
|
366 |
|
kpeter@734
|
367 |
/// %Invalid constructor \& conversion.
|
deba@57
|
368 |
|
kpeter@734
|
369 |
/// Initializes the iterator to be invalid.
|
kpeter@734
|
370 |
/// \sa Invalid for more details.
|
kpeter@734
|
371 |
IncEdgeIt(Invalid) { }
|
kpeter@734
|
372 |
/// Sets the iterator to the first incident edge.
|
kpeter@734
|
373 |
|
kpeter@734
|
374 |
/// Sets the iterator to the first incident edge of the given node.
|
deba@57
|
375 |
///
|
kpeter@734
|
376 |
IncEdgeIt(const Graph&, const Node&) { }
|
kpeter@734
|
377 |
/// Sets the iterator to the given edge.
|
alpar@209
|
378 |
|
kpeter@734
|
379 |
/// Sets the iterator to the given edge of the given graph.
|
kpeter@734
|
380 |
///
|
kpeter@734
|
381 |
IncEdgeIt(const Graph&, const Edge&) { }
|
kpeter@734
|
382 |
/// Next incident edge
|
deba@57
|
383 |
|
kpeter@734
|
384 |
/// Assign the iterator to the next incident edge
|
alpar@209
|
385 |
/// of the corresponding node.
|
deba@78
|
386 |
IncEdgeIt& operator++() { return *this; }
|
deba@57
|
387 |
};
|
deba@57
|
388 |
|
ggab90@1130
|
389 |
/// \brief Gets the collection of the incident undirected edges
|
ggab90@1130
|
390 |
/// of a certain node of the graph.
|
ggab90@1130
|
391 |
///
|
ggab90@1130
|
392 |
/// This function can be used for iterating on the
|
ggab90@1130
|
393 |
/// incident undirected edges of a certain node of the graph.
|
ggab90@1130
|
394 |
/// It returns a wrapped
|
ggab90@1130
|
395 |
/// IncEdgeIt, which looks like an STL container
|
ggab90@1130
|
396 |
/// (by having begin() and end()) which you can use in range-based
|
ggab90@1130
|
397 |
/// for loops, STL algorithms, etc.
|
ggab90@1130
|
398 |
/// For example if g is a Graph and u is a Node, you can write:
|
ggab90@1130
|
399 |
///\code
|
ggab90@1130
|
400 |
/// for(auto e: g.incEdges(u))
|
ggab90@1130
|
401 |
/// doSomething(e);
|
ggab90@1130
|
402 |
///
|
ggab90@1130
|
403 |
/// //Using an STL algorithm:
|
ggab90@1130
|
404 |
/// copy(g.incEdges(u).begin(), g.incEdges(u).end(), vect.begin());
|
ggab90@1130
|
405 |
///\endcode
|
ggab90@1130
|
406 |
LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
|
ggab90@1130
|
407 |
return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
|
ggab90@1130
|
408 |
}
|
ggab90@1130
|
409 |
|
ggab90@1130
|
410 |
|
kpeter@734
|
411 |
/// The arc type of the graph
|
deba@57
|
412 |
|
kpeter@734
|
413 |
/// This class identifies a directed arc of the graph. It also serves
|
kpeter@734
|
414 |
/// as a base class of the arc iterators,
|
kpeter@734
|
415 |
/// thus they will convert to this type.
|
kpeter@657
|
416 |
class Arc {
|
deba@57
|
417 |
public:
|
deba@57
|
418 |
/// Default constructor
|
deba@57
|
419 |
|
kpeter@734
|
420 |
/// Default constructor.
|
kpeter@734
|
421 |
/// \warning It sets the object to an undefined value.
|
deba@57
|
422 |
Arc() { }
|
deba@57
|
423 |
/// Copy constructor.
|
deba@57
|
424 |
|
deba@57
|
425 |
/// Copy constructor.
|
deba@57
|
426 |
///
|
kpeter@657
|
427 |
Arc(const Arc&) { }
|
alpar@1210
|
428 |
/// Assignment operator
|
alpar@1210
|
429 |
|
alpar@1210
|
430 |
/// Assignment operator.
|
alpar@1210
|
431 |
///
|
alpar@1210
|
432 |
const Arc &operator=(const Arc&) { return *this; }
|
alpar@1210
|
433 |
|
kpeter@734
|
434 |
/// %Invalid constructor \& conversion.
|
deba@57
|
435 |
|
kpeter@734
|
436 |
/// Initializes the object to be invalid.
|
kpeter@734
|
437 |
/// \sa Invalid for more details.
|
deba@57
|
438 |
Arc(Invalid) { }
|
deba@57
|
439 |
/// Equality operator
|
deba@57
|
440 |
|
kpeter@734
|
441 |
/// Equality operator.
|
kpeter@734
|
442 |
///
|
deba@57
|
443 |
/// Two iterators are equal if and only if they point to the
|
kpeter@734
|
444 |
/// same object or both are \c INVALID.
|
deba@57
|
445 |
bool operator==(Arc) const { return true; }
|
deba@57
|
446 |
/// Inequality operator
|
deba@57
|
447 |
|
kpeter@734
|
448 |
/// Inequality operator.
|
deba@57
|
449 |
bool operator!=(Arc) const { return true; }
|
deba@57
|
450 |
|
alpar@209
|
451 |
/// Artificial ordering operator.
|
alpar@209
|
452 |
|
kpeter@734
|
453 |
/// Artificial ordering operator.
|
alpar@209
|
454 |
///
|
kpeter@734
|
455 |
/// \note This operator only has to define some strict ordering of
|
kpeter@734
|
456 |
/// the arcs; this order has nothing to do with the iteration
|
kpeter@734
|
457 |
/// ordering of the arcs.
|
alpar@209
|
458 |
bool operator<(Arc) const { return false; }
|
alpar@209
|
459 |
|
kpeter@734
|
460 |
/// Converison to \c Edge
|
alpar@877
|
461 |
|
kpeter@734
|
462 |
/// Converison to \c Edge.
|
kpeter@734
|
463 |
///
|
kpeter@657
|
464 |
operator Edge() const { return Edge(); }
|
alpar@209
|
465 |
};
|
deba@57
|
466 |
|
kpeter@734
|
467 |
/// Iterator class for the arcs.
|
kpeter@734
|
468 |
|
kpeter@734
|
469 |
/// This iterator goes through each directed arc of the graph.
|
kpeter@786
|
470 |
/// Its usage is quite simple, for example, you can count the number
|
kpeter@734
|
471 |
/// of arcs in a graph \c g of type \c %Graph as follows:
|
deba@57
|
472 |
///\code
|
deba@57
|
473 |
/// int count=0;
|
kpeter@734
|
474 |
/// for(Graph::ArcIt a(g); a!=INVALID; ++a) ++count;
|
deba@57
|
475 |
///\endcode
|
deba@57
|
476 |
class ArcIt : public Arc {
|
deba@57
|
477 |
public:
|
deba@57
|
478 |
/// Default constructor
|
deba@57
|
479 |
|
kpeter@734
|
480 |
/// Default constructor.
|
kpeter@734
|
481 |
/// \warning It sets the iterator to an undefined value.
|
deba@57
|
482 |
ArcIt() { }
|
deba@57
|
483 |
/// Copy constructor.
|
deba@57
|
484 |
|
deba@57
|
485 |
/// Copy constructor.
|
deba@57
|
486 |
///
|
deba@57
|
487 |
ArcIt(const ArcIt& e) : Arc(e) { }
|
alpar@1210
|
488 |
/// Assignment operator
|
alpar@1210
|
489 |
|
alpar@1210
|
490 |
/// Assignment operator.
|
alpar@1210
|
491 |
///
|
alpar@1210
|
492 |
const ArcIt &operator=(const ArcIt&) { return *this; }
|
alpar@1210
|
493 |
|
kpeter@734
|
494 |
/// %Invalid constructor \& conversion.
|
deba@57
|
495 |
|
kpeter@734
|
496 |
/// Initializes the iterator to be invalid.
|
kpeter@734
|
497 |
/// \sa Invalid for more details.
|
kpeter@734
|
498 |
ArcIt(Invalid) { }
|
kpeter@734
|
499 |
/// Sets the iterator to the first arc.
|
kpeter@734
|
500 |
|
kpeter@734
|
501 |
/// Sets the iterator to the first arc of the given graph.
|
deba@57
|
502 |
///
|
alpar@1093
|
503 |
explicit ArcIt(const Graph &g) {
|
alpar@1093
|
504 |
::lemon::ignore_unused_variable_warning(g);
|
alpar@1093
|
505 |
}
|
kpeter@734
|
506 |
/// Sets the iterator to the given arc.
|
alpar@209
|
507 |
|
kpeter@734
|
508 |
/// Sets the iterator to the given arc of the given graph.
|
kpeter@734
|
509 |
///
|
alpar@209
|
510 |
ArcIt(const Graph&, const Arc&) { }
|
kpeter@734
|
511 |
/// Next arc
|
alpar@209
|
512 |
|
deba@57
|
513 |
/// Assign the iterator to the next arc.
|
kpeter@734
|
514 |
///
|
deba@57
|
515 |
ArcIt& operator++() { return *this; }
|
deba@57
|
516 |
};
|
alpar@209
|
517 |
|
ggab90@1130
|
518 |
/// \brief Gets the collection of the directed arcs of the graph.
|
ggab90@1130
|
519 |
///
|
ggab90@1130
|
520 |
/// This function can be used for iterating on the
|
ggab90@1130
|
521 |
/// arcs of the graph. It returns a wrapped
|
ggab90@1130
|
522 |
/// ArcIt, which looks like an STL container
|
ggab90@1130
|
523 |
/// (by having begin() and end()) which you can use in range-based
|
ggab90@1130
|
524 |
/// for loops, STL algorithms, etc.
|
ggab90@1130
|
525 |
/// For example you can write:
|
ggab90@1130
|
526 |
///\code
|
ggab90@1130
|
527 |
/// ListGraph g;
|
ggab90@1130
|
528 |
/// for(auto a: g.arcs())
|
ggab90@1130
|
529 |
/// doSomething(a);
|
ggab90@1130
|
530 |
///
|
ggab90@1130
|
531 |
/// //Using an STL algorithm:
|
ggab90@1130
|
532 |
/// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
|
ggab90@1130
|
533 |
///\endcode
|
ggab90@1130
|
534 |
LemonRangeWrapper1<ArcIt, Graph> arcs() const {
|
ggab90@1130
|
535 |
return LemonRangeWrapper1<ArcIt, Graph>(*this);
|
ggab90@1130
|
536 |
}
|
ggab90@1130
|
537 |
|
ggab90@1130
|
538 |
|
kpeter@734
|
539 |
/// Iterator class for the outgoing arcs of a node.
|
deba@57
|
540 |
|
kpeter@734
|
541 |
/// This iterator goes trough the \e outgoing directed arcs of a
|
kpeter@734
|
542 |
/// certain node of a graph.
|
kpeter@786
|
543 |
/// Its usage is quite simple, for example, you can count the number
|
deba@57
|
544 |
/// of outgoing arcs of a node \c n
|
kpeter@734
|
545 |
/// in a graph \c g of type \c %Graph as follows.
|
deba@57
|
546 |
///\code
|
deba@57
|
547 |
/// int count=0;
|
kpeter@734
|
548 |
/// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
|
deba@57
|
549 |
///\endcode
|
deba@57
|
550 |
class OutArcIt : public Arc {
|
deba@57
|
551 |
public:
|
deba@57
|
552 |
/// Default constructor
|
deba@57
|
553 |
|
kpeter@734
|
554 |
/// Default constructor.
|
kpeter@734
|
555 |
/// \warning It sets the iterator to an undefined value.
|
deba@57
|
556 |
OutArcIt() { }
|
deba@57
|
557 |
/// Copy constructor.
|
deba@57
|
558 |
|
deba@57
|
559 |
/// Copy constructor.
|
deba@57
|
560 |
///
|
deba@57
|
561 |
OutArcIt(const OutArcIt& e) : Arc(e) { }
|
alpar@1210
|
562 |
/// Assignment operator
|
alpar@1210
|
563 |
|
alpar@1210
|
564 |
/// Assignment operator.
|
alpar@1210
|
565 |
///
|
alpar@1210
|
566 |
const OutArcIt &operator=(const OutArcIt&) { return *this; }
|
alpar@1210
|
567 |
|
kpeter@734
|
568 |
/// %Invalid constructor \& conversion.
|
deba@57
|
569 |
|
kpeter@734
|
570 |
/// Initializes the iterator to be invalid.
|
kpeter@734
|
571 |
/// \sa Invalid for more details.
|
kpeter@734
|
572 |
OutArcIt(Invalid) { }
|
kpeter@734
|
573 |
/// Sets the iterator to the first outgoing arc.
|
kpeter@734
|
574 |
|
kpeter@734
|
575 |
/// Sets the iterator to the first outgoing arc of the given node.
|
deba@57
|
576 |
///
|
deba@57
|
577 |
OutArcIt(const Graph& n, const Node& g) {
|
alpar@1083
|
578 |
::lemon::ignore_unused_variable_warning(n);
|
alpar@1083
|
579 |
::lemon::ignore_unused_variable_warning(g);
|
alpar@209
|
580 |
}
|
kpeter@734
|
581 |
/// Sets the iterator to the given arc.
|
deba@57
|
582 |
|
kpeter@734
|
583 |
/// Sets the iterator to the given arc of the given graph.
|
kpeter@734
|
584 |
///
|
deba@57
|
585 |
OutArcIt(const Graph&, const Arc&) { }
|
kpeter@734
|
586 |
/// Next outgoing arc
|
alpar@209
|
587 |
|
alpar@209
|
588 |
/// Assign the iterator to the next
|
deba@57
|
589 |
/// outgoing arc of the corresponding node.
|
deba@57
|
590 |
OutArcIt& operator++() { return *this; }
|
deba@57
|
591 |
};
|
deba@57
|
592 |
|
ggab90@1130
|
593 |
/// \brief Gets the collection of the outgoing directed arcs of a
|
ggab90@1130
|
594 |
/// certain node of the graph.
|
ggab90@1130
|
595 |
///
|
ggab90@1130
|
596 |
/// This function can be used for iterating on the
|
ggab90@1130
|
597 |
/// outgoing arcs of a certain node of the graph. It returns a wrapped
|
ggab90@1130
|
598 |
/// OutArcIt, which looks like an STL container
|
ggab90@1130
|
599 |
/// (by having begin() and end()) which you can use in range-based
|
ggab90@1130
|
600 |
/// for loops, STL algorithms, etc.
|
ggab90@1130
|
601 |
/// For example if g is a Graph and u is a Node, you can write:
|
ggab90@1130
|
602 |
///\code
|
ggab90@1130
|
603 |
/// for(auto a: g.outArcs(u))
|
ggab90@1130
|
604 |
/// doSomething(a);
|
ggab90@1130
|
605 |
///
|
ggab90@1130
|
606 |
/// //Using an STL algorithm:
|
ggab90@1130
|
607 |
/// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
|
ggab90@1130
|
608 |
///\endcode
|
ggab90@1130
|
609 |
LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
|
ggab90@1130
|
610 |
return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
|
ggab90@1130
|
611 |
}
|
ggab90@1130
|
612 |
|
ggab90@1130
|
613 |
|
kpeter@734
|
614 |
/// Iterator class for the incoming arcs of a node.
|
deba@57
|
615 |
|
kpeter@734
|
616 |
/// This iterator goes trough the \e incoming directed arcs of a
|
kpeter@734
|
617 |
/// certain node of a graph.
|
kpeter@786
|
618 |
/// Its usage is quite simple, for example, you can count the number
|
kpeter@734
|
619 |
/// of incoming arcs of a node \c n
|
kpeter@734
|
620 |
/// in a graph \c g of type \c %Graph as follows.
|
deba@57
|
621 |
///\code
|
deba@57
|
622 |
/// int count=0;
|
kpeter@734
|
623 |
/// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
|
deba@57
|
624 |
///\endcode
|
deba@57
|
625 |
class InArcIt : public Arc {
|
deba@57
|
626 |
public:
|
deba@57
|
627 |
/// Default constructor
|
deba@57
|
628 |
|
kpeter@734
|
629 |
/// Default constructor.
|
kpeter@734
|
630 |
/// \warning It sets the iterator to an undefined value.
|
deba@57
|
631 |
InArcIt() { }
|
deba@57
|
632 |
/// Copy constructor.
|
deba@57
|
633 |
|
deba@57
|
634 |
/// Copy constructor.
|
deba@57
|
635 |
///
|
deba@57
|
636 |
InArcIt(const InArcIt& e) : Arc(e) { }
|
alpar@1210
|
637 |
/// Assignment operator
|
alpar@1210
|
638 |
|
alpar@1210
|
639 |
/// Assignment operator.
|
alpar@1210
|
640 |
///
|
alpar@1210
|
641 |
const InArcIt &operator=(const InArcIt&) { return *this; }
|
alpar@1210
|
642 |
|
kpeter@734
|
643 |
/// %Invalid constructor \& conversion.
|
deba@57
|
644 |
|
kpeter@734
|
645 |
/// Initializes the iterator to be invalid.
|
kpeter@734
|
646 |
/// \sa Invalid for more details.
|
kpeter@734
|
647 |
InArcIt(Invalid) { }
|
kpeter@734
|
648 |
/// Sets the iterator to the first incoming arc.
|
kpeter@734
|
649 |
|
kpeter@734
|
650 |
/// Sets the iterator to the first incoming arc of the given node.
|
deba@57
|
651 |
///
|
alpar@209
|
652 |
InArcIt(const Graph& g, const Node& n) {
|
alpar@1083
|
653 |
::lemon::ignore_unused_variable_warning(n);
|
alpar@1083
|
654 |
::lemon::ignore_unused_variable_warning(g);
|
alpar@209
|
655 |
}
|
kpeter@734
|
656 |
/// Sets the iterator to the given arc.
|
deba@57
|
657 |
|
kpeter@734
|
658 |
/// Sets the iterator to the given arc of the given graph.
|
kpeter@734
|
659 |
///
|
deba@57
|
660 |
InArcIt(const Graph&, const Arc&) { }
|
deba@57
|
661 |
/// Next incoming arc
|
deba@57
|
662 |
|
kpeter@734
|
663 |
/// Assign the iterator to the next
|
kpeter@734
|
664 |
/// incoming arc of the corresponding node.
|
deba@57
|
665 |
InArcIt& operator++() { return *this; }
|
deba@57
|
666 |
};
|
deba@57
|
667 |
|
ggab90@1130
|
668 |
/// \brief Gets the collection of the incoming directed arcs of
|
ggab90@1130
|
669 |
/// a certain node of the graph.
|
ggab90@1130
|
670 |
///
|
ggab90@1130
|
671 |
/// This function can be used for iterating on the
|
ggab90@1130
|
672 |
/// incoming directed arcs of a certain node of the graph. It returns
|
ggab90@1130
|
673 |
/// a wrapped InArcIt, which looks like an STL container
|
ggab90@1130
|
674 |
/// (by having begin() and end()) which you can use in range-based
|
ggab90@1130
|
675 |
/// for loops, STL algorithms, etc.
|
ggab90@1130
|
676 |
/// For example if g is a Graph and u is a Node, you can write:
|
ggab90@1130
|
677 |
///\code
|
ggab90@1130
|
678 |
/// for(auto a: g.inArcs(u))
|
ggab90@1130
|
679 |
/// doSomething(a);
|
ggab90@1130
|
680 |
///
|
ggab90@1130
|
681 |
/// //Using an STL algorithm:
|
ggab90@1130
|
682 |
/// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
|
ggab90@1130
|
683 |
///\endcode
|
ggab90@1130
|
684 |
LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
|
ggab90@1130
|
685 |
return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
|
ggab90@1130
|
686 |
}
|
ggab90@1130
|
687 |
|
kpeter@734
|
688 |
/// \brief Standard graph map type for the nodes.
|
alpar@209
|
689 |
///
|
kpeter@734
|
690 |
/// Standard graph map type for the nodes.
|
kpeter@734
|
691 |
/// It conforms to the ReferenceMap concept.
|
alpar@209
|
692 |
template<class T>
|
kpeter@580
|
693 |
class NodeMap : public ReferenceMap<Node, T, T&, const T&>
|
deba@57
|
694 |
{
|
deba@57
|
695 |
public:
|
deba@57
|
696 |
|
kpeter@734
|
697 |
/// Constructor
|
kpeter@734
|
698 |
explicit NodeMap(const Graph&) { }
|
kpeter@734
|
699 |
/// Constructor with given initial value
|
deba@57
|
700 |
NodeMap(const Graph&, T) { }
|
deba@57
|
701 |
|
kpeter@263
|
702 |
private:
|
deba@57
|
703 |
///Copy constructor
|
kpeter@580
|
704 |
NodeMap(const NodeMap& nm) :
|
kpeter@580
|
705 |
ReferenceMap<Node, T, T&, const T&>(nm) { }
|
deba@57
|
706 |
///Assignment operator
|
alpar@1210
|
707 |
NodeMap& operator=(const NodeMap&) {
|
alpar@1210
|
708 |
return *this;
|
alpar@1210
|
709 |
}
|
alpar@1210
|
710 |
///Template Assignment operator
|
deba@57
|
711 |
template <typename CMap>
|
alpar@209
|
712 |
NodeMap& operator=(const CMap&) {
|
deba@57
|
713 |
checkConcept<ReadMap<Node, T>, CMap>();
|
alpar@209
|
714 |
return *this;
|
deba@57
|
715 |
}
|
deba@57
|
716 |
};
|
deba@57
|
717 |
|
kpeter@734
|
718 |
/// \brief Standard graph map type for the arcs.
|
deba@57
|
719 |
///
|
kpeter@734
|
720 |
/// Standard graph map type for the arcs.
|
kpeter@734
|
721 |
/// It conforms to the ReferenceMap concept.
|
alpar@209
|
722 |
template<class T>
|
kpeter@580
|
723 |
class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
|
deba@57
|
724 |
{
|
deba@57
|
725 |
public:
|
deba@57
|
726 |
|
kpeter@734
|
727 |
/// Constructor
|
kpeter@734
|
728 |
explicit ArcMap(const Graph&) { }
|
kpeter@734
|
729 |
/// Constructor with given initial value
|
deba@57
|
730 |
ArcMap(const Graph&, T) { }
|
kpeter@734
|
731 |
|
kpeter@263
|
732 |
private:
|
deba@57
|
733 |
///Copy constructor
|
kpeter@580
|
734 |
ArcMap(const ArcMap& em) :
|
kpeter@580
|
735 |
ReferenceMap<Arc, T, T&, const T&>(em) { }
|
deba@57
|
736 |
///Assignment operator
|
alpar@1210
|
737 |
ArcMap& operator=(const ArcMap&) {
|
alpar@1210
|
738 |
return *this;
|
alpar@1210
|
739 |
}
|
alpar@1210
|
740 |
///Template Assignment operator
|
deba@57
|
741 |
template <typename CMap>
|
alpar@209
|
742 |
ArcMap& operator=(const CMap&) {
|
deba@57
|
743 |
checkConcept<ReadMap<Arc, T>, CMap>();
|
alpar@209
|
744 |
return *this;
|
deba@57
|
745 |
}
|
deba@57
|
746 |
};
|
deba@57
|
747 |
|
kpeter@734
|
748 |
/// \brief Standard graph map type for the edges.
|
kpeter@734
|
749 |
///
|
kpeter@734
|
750 |
/// Standard graph map type for the edges.
|
kpeter@734
|
751 |
/// It conforms to the ReferenceMap concept.
|
alpar@209
|
752 |
template<class T>
|
kpeter@580
|
753 |
class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
|
deba@57
|
754 |
{
|
deba@57
|
755 |
public:
|
deba@57
|
756 |
|
kpeter@734
|
757 |
/// Constructor
|
kpeter@734
|
758 |
explicit EdgeMap(const Graph&) { }
|
kpeter@734
|
759 |
/// Constructor with given initial value
|
deba@57
|
760 |
EdgeMap(const Graph&, T) { }
|
kpeter@734
|
761 |
|
kpeter@263
|
762 |
private:
|
deba@57
|
763 |
///Copy constructor
|
kpeter@580
|
764 |
EdgeMap(const EdgeMap& em) :
|
kpeter@580
|
765 |
ReferenceMap<Edge, T, T&, const T&>(em) {}
|
deba@57
|
766 |
///Assignment operator
|
alpar@1210
|
767 |
EdgeMap& operator=(const EdgeMap&) {
|
alpar@1210
|
768 |
return *this;
|
alpar@1210
|
769 |
}
|
alpar@1210
|
770 |
///Template Assignment operator
|
deba@57
|
771 |
template <typename CMap>
|
alpar@209
|
772 |
EdgeMap& operator=(const CMap&) {
|
deba@57
|
773 |
checkConcept<ReadMap<Edge, T>, CMap>();
|
alpar@209
|
774 |
return *this;
|
deba@57
|
775 |
}
|
deba@57
|
776 |
};
|
deba@57
|
777 |
|
kpeter@734
|
778 |
/// \brief The first node of the edge.
|
deba@57
|
779 |
///
|
kpeter@734
|
780 |
/// Returns the first node of the given edge.
|
deba@57
|
781 |
///
|
kpeter@786
|
782 |
/// Edges don't have source and target nodes, however, methods
|
kpeter@734
|
783 |
/// u() and v() are used to query the two end-nodes of an edge.
|
kpeter@734
|
784 |
/// The orientation of an edge that arises this way is called
|
kpeter@734
|
785 |
/// the inherent direction, it is used to define the default
|
kpeter@734
|
786 |
/// direction for the corresponding arcs.
|
kpeter@559
|
787 |
/// \sa v()
|
kpeter@559
|
788 |
/// \sa direction()
|
deba@57
|
789 |
Node u(Edge) const { return INVALID; }
|
deba@57
|
790 |
|
kpeter@734
|
791 |
/// \brief The second node of the edge.
|
kpeter@559
|
792 |
///
|
kpeter@734
|
793 |
/// Returns the second node of the given edge.
|
kpeter@559
|
794 |
///
|
kpeter@786
|
795 |
/// Edges don't have source and target nodes, however, methods
|
kpeter@734
|
796 |
/// u() and v() are used to query the two end-nodes of an edge.
|
kpeter@734
|
797 |
/// The orientation of an edge that arises this way is called
|
kpeter@734
|
798 |
/// the inherent direction, it is used to define the default
|
kpeter@734
|
799 |
/// direction for the corresponding arcs.
|
kpeter@559
|
800 |
/// \sa u()
|
kpeter@559
|
801 |
/// \sa direction()
|
deba@57
|
802 |
Node v(Edge) const { return INVALID; }
|
deba@57
|
803 |
|
kpeter@734
|
804 |
/// \brief The source node of the arc.
|
kpeter@734
|
805 |
///
|
kpeter@734
|
806 |
/// Returns the source node of the given arc.
|
deba@57
|
807 |
Node source(Arc) const { return INVALID; }
|
deba@57
|
808 |
|
kpeter@734
|
809 |
/// \brief The target node of the arc.
|
kpeter@734
|
810 |
///
|
kpeter@734
|
811 |
/// Returns the target node of the given arc.
|
deba@57
|
812 |
Node target(Arc) const { return INVALID; }
|
deba@57
|
813 |
|
kpeter@734
|
814 |
/// \brief The ID of the node.
|
kpeter@734
|
815 |
///
|
kpeter@734
|
816 |
/// Returns the ID of the given node.
|
alpar@209
|
817 |
int id(Node) const { return -1; }
|
deba@61
|
818 |
|
kpeter@734
|
819 |
/// \brief The ID of the edge.
|
kpeter@734
|
820 |
///
|
kpeter@734
|
821 |
/// Returns the ID of the given edge.
|
alpar@209
|
822 |
int id(Edge) const { return -1; }
|
deba@61
|
823 |
|
kpeter@734
|
824 |
/// \brief The ID of the arc.
|
kpeter@734
|
825 |
///
|
kpeter@734
|
826 |
/// Returns the ID of the given arc.
|
alpar@209
|
827 |
int id(Arc) const { return -1; }
|
deba@61
|
828 |
|
kpeter@734
|
829 |
/// \brief The node with the given ID.
|
deba@61
|
830 |
///
|
kpeter@734
|
831 |
/// Returns the node with the given ID.
|
kpeter@734
|
832 |
/// \pre The argument should be a valid node ID in the graph.
|
alpar@209
|
833 |
Node nodeFromId(int) const { return INVALID; }
|
deba@61
|
834 |
|
kpeter@734
|
835 |
/// \brief The edge with the given ID.
|
deba@61
|
836 |
///
|
kpeter@734
|
837 |
/// Returns the edge with the given ID.
|
kpeter@734
|
838 |
/// \pre The argument should be a valid edge ID in the graph.
|
alpar@209
|
839 |
Edge edgeFromId(int) const { return INVALID; }
|
deba@61
|
840 |
|
kpeter@734
|
841 |
/// \brief The arc with the given ID.
|
deba@61
|
842 |
///
|
kpeter@734
|
843 |
/// Returns the arc with the given ID.
|
kpeter@734
|
844 |
/// \pre The argument should be a valid arc ID in the graph.
|
alpar@209
|
845 |
Arc arcFromId(int) const { return INVALID; }
|
deba@61
|
846 |
|
kpeter@734
|
847 |
/// \brief An upper bound on the node IDs.
|
kpeter@734
|
848 |
///
|
kpeter@734
|
849 |
/// Returns an upper bound on the node IDs.
|
alpar@209
|
850 |
int maxNodeId() const { return -1; }
|
deba@61
|
851 |
|
kpeter@734
|
852 |
/// \brief An upper bound on the edge IDs.
|
kpeter@734
|
853 |
///
|
kpeter@734
|
854 |
/// Returns an upper bound on the edge IDs.
|
alpar@209
|
855 |
int maxEdgeId() const { return -1; }
|
deba@61
|
856 |
|
kpeter@734
|
857 |
/// \brief An upper bound on the arc IDs.
|
kpeter@734
|
858 |
///
|
kpeter@734
|
859 |
/// Returns an upper bound on the arc IDs.
|
alpar@209
|
860 |
int maxArcId() const { return -1; }
|
deba@61
|
861 |
|
kpeter@734
|
862 |
/// \brief The direction of the arc.
|
kpeter@734
|
863 |
///
|
kpeter@734
|
864 |
/// Returns \c true if the direction of the given arc is the same as
|
kpeter@734
|
865 |
/// the inherent orientation of the represented edge.
|
kpeter@734
|
866 |
bool direction(Arc) const { return true; }
|
kpeter@734
|
867 |
|
kpeter@734
|
868 |
/// \brief Direct the edge.
|
kpeter@734
|
869 |
///
|
kpeter@734
|
870 |
/// Direct the given edge. The returned arc
|
kpeter@734
|
871 |
/// represents the given edge and its direction comes
|
kpeter@734
|
872 |
/// from the bool parameter. If it is \c true, then the direction
|
kpeter@734
|
873 |
/// of the arc is the same as the inherent orientation of the edge.
|
kpeter@734
|
874 |
Arc direct(Edge, bool) const {
|
kpeter@734
|
875 |
return INVALID;
|
kpeter@734
|
876 |
}
|
kpeter@734
|
877 |
|
kpeter@734
|
878 |
/// \brief Direct the edge.
|
kpeter@734
|
879 |
///
|
kpeter@734
|
880 |
/// Direct the given edge. The returned arc represents the given
|
kpeter@734
|
881 |
/// edge and its source node is the given node.
|
kpeter@734
|
882 |
Arc direct(Edge, Node) const {
|
kpeter@734
|
883 |
return INVALID;
|
kpeter@734
|
884 |
}
|
kpeter@734
|
885 |
|
kpeter@734
|
886 |
/// \brief The oppositely directed arc.
|
kpeter@734
|
887 |
///
|
kpeter@734
|
888 |
/// Returns the oppositely directed arc representing the same edge.
|
kpeter@734
|
889 |
Arc oppositeArc(Arc) const { return INVALID; }
|
kpeter@734
|
890 |
|
kpeter@734
|
891 |
/// \brief The opposite node on the edge.
|
kpeter@734
|
892 |
///
|
kpeter@734
|
893 |
/// Returns the opposite node on the given edge.
|
kpeter@734
|
894 |
Node oppositeNode(Node, Edge) const { return INVALID; }
|
kpeter@734
|
895 |
|
deba@57
|
896 |
void first(Node&) const {}
|
deba@57
|
897 |
void next(Node&) const {}
|
deba@57
|
898 |
|
deba@57
|
899 |
void first(Edge&) const {}
|
deba@57
|
900 |
void next(Edge&) const {}
|
deba@57
|
901 |
|
deba@57
|
902 |
void first(Arc&) const {}
|
deba@57
|
903 |
void next(Arc&) const {}
|
deba@57
|
904 |
|
deba@57
|
905 |
void firstOut(Arc&, Node) const {}
|
deba@57
|
906 |
void nextOut(Arc&) const {}
|
deba@57
|
907 |
|
deba@57
|
908 |
void firstIn(Arc&, Node) const {}
|
deba@57
|
909 |
void nextIn(Arc&) const {}
|
deba@57
|
910 |
|
deba@57
|
911 |
void firstInc(Edge &, bool &, const Node &) const {}
|
deba@57
|
912 |
void nextInc(Edge &, bool &) const {}
|
deba@57
|
913 |
|
deba@61
|
914 |
// The second parameter is dummy.
|
deba@61
|
915 |
Node fromId(int, Node) const { return INVALID; }
|
deba@61
|
916 |
// The second parameter is dummy.
|
deba@61
|
917 |
Edge fromId(int, Edge) const { return INVALID; }
|
deba@61
|
918 |
// The second parameter is dummy.
|
deba@61
|
919 |
Arc fromId(int, Arc) const { return INVALID; }
|
deba@61
|
920 |
|
deba@61
|
921 |
// Dummy parameter.
|
alpar@209
|
922 |
int maxId(Node) const { return -1; }
|
deba@61
|
923 |
// Dummy parameter.
|
alpar@209
|
924 |
int maxId(Edge) const { return -1; }
|
deba@61
|
925 |
// Dummy parameter.
|
alpar@209
|
926 |
int maxId(Arc) const { return -1; }
|
deba@61
|
927 |
|
kpeter@734
|
928 |
/// \brief The base node of the iterator.
|
deba@57
|
929 |
///
|
kpeter@734
|
930 |
/// Returns the base node of the given incident edge iterator.
|
kpeter@734
|
931 |
Node baseNode(IncEdgeIt) const { return INVALID; }
|
kpeter@734
|
932 |
|
kpeter@734
|
933 |
/// \brief The running node of the iterator.
|
deba@57
|
934 |
///
|
kpeter@734
|
935 |
/// Returns the running node of the given incident edge iterator.
|
kpeter@734
|
936 |
Node runningNode(IncEdgeIt) const { return INVALID; }
|
deba@57
|
937 |
|
kpeter@734
|
938 |
/// \brief The base node of the iterator.
|
deba@57
|
939 |
///
|
kpeter@734
|
940 |
/// Returns the base node of the given outgoing arc iterator
|
kpeter@734
|
941 |
/// (i.e. the source node of the corresponding arc).
|
kpeter@734
|
942 |
Node baseNode(OutArcIt) const { return INVALID; }
|
kpeter@734
|
943 |
|
kpeter@734
|
944 |
/// \brief The running node of the iterator.
|
deba@57
|
945 |
///
|
kpeter@734
|
946 |
/// Returns the running node of the given outgoing arc iterator
|
kpeter@734
|
947 |
/// (i.e. the target node of the corresponding arc).
|
kpeter@734
|
948 |
Node runningNode(OutArcIt) const { return INVALID; }
|
deba@57
|
949 |
|
kpeter@734
|
950 |
/// \brief The base node of the iterator.
|
deba@57
|
951 |
///
|
kpeter@1049
|
952 |
/// Returns the base node of the given incoming arc iterator
|
kpeter@734
|
953 |
/// (i.e. the target node of the corresponding arc).
|
kpeter@734
|
954 |
Node baseNode(InArcIt) const { return INVALID; }
|
alpar@209
|
955 |
|
kpeter@734
|
956 |
/// \brief The running node of the iterator.
|
deba@57
|
957 |
///
|
kpeter@1049
|
958 |
/// Returns the running node of the given incoming arc iterator
|
kpeter@734
|
959 |
/// (i.e. the source node of the corresponding arc).
|
kpeter@734
|
960 |
Node runningNode(InArcIt) const { return INVALID; }
|
deba@57
|
961 |
|
deba@125
|
962 |
template <typename _Graph>
|
deba@57
|
963 |
struct Constraints {
|
alpar@209
|
964 |
void constraints() {
|
kpeter@580
|
965 |
checkConcept<BaseGraphComponent, _Graph>();
|
alpar@209
|
966 |
checkConcept<IterableGraphComponent<>, _Graph>();
|
alpar@209
|
967 |
checkConcept<IDableGraphComponent<>, _Graph>();
|
alpar@209
|
968 |
checkConcept<MappableGraphComponent<>, _Graph>();
|
alpar@209
|
969 |
}
|
deba@57
|
970 |
};
|
deba@57
|
971 |
|
deba@57
|
972 |
};
|
deba@57
|
973 |
|
deba@57
|
974 |
}
|
deba@57
|
975 |
|
deba@57
|
976 |
}
|
deba@57
|
977 |
|
deba@57
|
978 |
#endif
|