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