deba@1911
|
1 |
/* -*- C++ -*-
|
deba@1911
|
2 |
*
|
deba@1911
|
3 |
* lemon/concept/ugraph_component.h - Part of LEMON, a generic
|
deba@1911
|
4 |
* C++ optimization library
|
deba@1911
|
5 |
*
|
deba@1911
|
6 |
* Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi
|
deba@1911
|
7 |
* Kutatocsoport (Egervary Research Group on Combinatorial Optimization,
|
deba@1911
|
8 |
* EGRES).
|
deba@1911
|
9 |
*
|
deba@1911
|
10 |
* Permission to use, modify and distribute this software is granted
|
deba@1911
|
11 |
* provided that this copyright notice appears in all copies. For
|
deba@1911
|
12 |
* precise terms see the accompanying LICENSE file.
|
deba@1911
|
13 |
*
|
deba@1911
|
14 |
* This software is provided "AS IS" with no warranty of any kind,
|
deba@1911
|
15 |
* express or implied, and with no claim as to its suitability for any
|
deba@1911
|
16 |
* purpose.
|
deba@1911
|
17 |
*
|
deba@1911
|
18 |
*/
|
deba@1911
|
19 |
|
deba@1911
|
20 |
/// \ingroup graph_concepts
|
deba@1911
|
21 |
/// \file
|
deba@1911
|
22 |
/// \brief Undirected bipartite graphs and components of.
|
deba@1911
|
23 |
|
deba@1911
|
24 |
|
deba@1911
|
25 |
#ifndef LEMON_CONCEPT_BPUGRAPH_H
|
deba@1911
|
26 |
#define LEMON_CONCEPT_BPUGRAPH_H
|
deba@1911
|
27 |
|
deba@1911
|
28 |
#include <lemon/concept/graph_component.h>
|
deba@1911
|
29 |
|
deba@1911
|
30 |
#include <lemon/concept/graph.h>
|
deba@1911
|
31 |
#include <lemon/concept/ugraph.h>
|
deba@1911
|
32 |
|
deba@1911
|
33 |
#include <lemon/utility.h>
|
deba@1911
|
34 |
|
deba@1911
|
35 |
namespace lemon {
|
deba@1911
|
36 |
namespace concept {
|
deba@1911
|
37 |
|
deba@1911
|
38 |
/// \addtogroup graph_concepts
|
deba@1911
|
39 |
/// @{
|
deba@1911
|
40 |
|
deba@1911
|
41 |
|
deba@1911
|
42 |
/// \brief Class describing the concept of Bipartite Undirected Graphs.
|
deba@1911
|
43 |
///
|
deba@1911
|
44 |
/// This class describes the common interface of all
|
deba@1911
|
45 |
/// Undirected Bipartite Graphs.
|
deba@1911
|
46 |
///
|
deba@1911
|
47 |
/// As all concept describing classes it provides only interface
|
deba@1911
|
48 |
/// without any sensible implementation. So any algorithm for
|
deba@1911
|
49 |
/// bipartite undirected graph should compile with this class, but it
|
deba@1911
|
50 |
/// will not run properly, of course.
|
deba@1911
|
51 |
///
|
deba@1911
|
52 |
/// In LEMON bipartite undirected graphs also fulfill the concept of
|
deba@1911
|
53 |
/// the undirected graphs (\ref lemon::concept::UGraph "UGraph Concept").
|
deba@1911
|
54 |
///
|
deba@1911
|
55 |
/// You can assume that all undirected bipartite graph can be handled
|
deba@1911
|
56 |
/// as an undirected graph and consequently as a static graph.
|
deba@1911
|
57 |
///
|
deba@1911
|
58 |
/// The bipartite graph stores two types of nodes which are named
|
deba@1933
|
59 |
/// ANode and BNode. The graph type contains two types ANode and BNode
|
deba@1933
|
60 |
/// which are inherited from Node type. Moreover they have
|
deba@1933
|
61 |
/// constructor which converts Node to either ANode or BNode when it is
|
deba@1933
|
62 |
/// possible. Therefor everywhere the Node type can be used instead of
|
deba@1933
|
63 |
/// ANode and BNode. So the usage of the ANode and BNode is suggested.
|
deba@1911
|
64 |
///
|
deba@1911
|
65 |
/// The iteration on the partition can be done with the ANodeIt and
|
deba@1911
|
66 |
/// BNodeIt classes. The node map can be used to map values to the nodes
|
deba@1911
|
67 |
/// and similarly we can use to map values for just the ANodes and
|
deba@1911
|
68 |
/// BNodes the ANodeMap and BNodeMap template classes.
|
deba@1911
|
69 |
|
deba@1911
|
70 |
class BpUGraph {
|
deba@1911
|
71 |
public:
|
deba@1911
|
72 |
/// \todo undocumented
|
deba@1911
|
73 |
///
|
deba@1911
|
74 |
typedef True UTag;
|
deba@1911
|
75 |
|
deba@1911
|
76 |
/// \brief The base type of node iterators,
|
deba@1911
|
77 |
/// or in other words, the trivial node iterator.
|
deba@1911
|
78 |
///
|
deba@1911
|
79 |
/// This is the base type of each node iterator,
|
deba@1911
|
80 |
/// thus each kind of node iterator converts to this.
|
deba@1911
|
81 |
/// More precisely each kind of node iterator should be inherited
|
deba@1911
|
82 |
/// from the trivial node iterator. The Node class represents
|
deba@1911
|
83 |
/// both of two types of nodes.
|
deba@1911
|
84 |
class Node {
|
deba@1911
|
85 |
public:
|
deba@1911
|
86 |
/// Default constructor
|
deba@1911
|
87 |
|
deba@1911
|
88 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
89 |
/// to an undefined value.
|
deba@1911
|
90 |
Node() { }
|
deba@1911
|
91 |
/// Copy constructor.
|
deba@1911
|
92 |
|
deba@1911
|
93 |
/// Copy constructor.
|
deba@1911
|
94 |
///
|
deba@1911
|
95 |
Node(const Node&) { }
|
deba@1911
|
96 |
|
deba@1911
|
97 |
/// Invalid constructor \& conversion.
|
deba@1911
|
98 |
|
deba@1911
|
99 |
/// This constructor initializes the iterator to be invalid.
|
deba@1911
|
100 |
/// \sa Invalid for more details.
|
deba@1911
|
101 |
Node(Invalid) { }
|
deba@1911
|
102 |
/// Equality operator
|
deba@1911
|
103 |
|
deba@1911
|
104 |
/// Two iterators are equal if and only if they point to the
|
deba@1911
|
105 |
/// same object or both are invalid.
|
deba@1911
|
106 |
bool operator==(Node) const { return true; }
|
deba@1911
|
107 |
|
deba@1911
|
108 |
/// Inequality operator
|
deba@1911
|
109 |
|
deba@1911
|
110 |
/// \sa operator==(Node n)
|
deba@1911
|
111 |
///
|
deba@1911
|
112 |
bool operator!=(Node) const { return true; }
|
deba@1911
|
113 |
|
deba@1911
|
114 |
/// Artificial ordering operator.
|
deba@1911
|
115 |
|
deba@1911
|
116 |
/// To allow the use of graph descriptors as key type in std::map or
|
deba@1911
|
117 |
/// similar associative container we require this.
|
deba@1911
|
118 |
///
|
deba@1911
|
119 |
/// \note This operator only have to define some strict ordering of
|
deba@1911
|
120 |
/// the items; this order has nothing to do with the iteration
|
deba@1911
|
121 |
/// ordering of the items.
|
deba@1911
|
122 |
///
|
deba@1911
|
123 |
/// \bug This is a technical requirement. Do we really need this?
|
deba@1911
|
124 |
bool operator<(Node) const { return false; }
|
deba@1911
|
125 |
|
deba@1911
|
126 |
};
|
deba@1933
|
127 |
|
deba@1933
|
128 |
/// \brief The base type of anode iterators,
|
deba@1933
|
129 |
/// or in other words, the trivial anode iterator.
|
deba@1933
|
130 |
///
|
deba@1933
|
131 |
/// This is the base type of each anode iterator,
|
deba@1933
|
132 |
/// thus each kind of anode iterator converts to this.
|
deba@1933
|
133 |
/// More precisely each kind of node iterator should be inherited
|
deba@1933
|
134 |
/// from the trivial anode iterator. The ANode class should be used
|
deba@1933
|
135 |
/// only in special cases. Usually the Node type should be used insted
|
deba@1933
|
136 |
/// of it.
|
deba@1933
|
137 |
class ANode {
|
deba@1933
|
138 |
public:
|
deba@1933
|
139 |
/// Default constructor
|
deba@1933
|
140 |
|
deba@1933
|
141 |
/// @warning The default constructor sets the iterator
|
deba@1933
|
142 |
/// to an undefined value.
|
deba@1933
|
143 |
ANode() { }
|
deba@1933
|
144 |
/// Copy constructor.
|
deba@1933
|
145 |
|
deba@1933
|
146 |
/// Copy constructor.
|
deba@1933
|
147 |
///
|
deba@1933
|
148 |
ANode(const ANode&) { }
|
deba@1933
|
149 |
|
deba@1933
|
150 |
/// Construct the same node as ANode.
|
deba@1933
|
151 |
|
deba@1933
|
152 |
/// Construct the same node as ANode. It may throws assertion
|
deba@1933
|
153 |
/// when the given node is from the BNode set.
|
deba@1933
|
154 |
ANode(const Node&) { }
|
deba@1933
|
155 |
|
deba@1933
|
156 |
/// Invalid constructor \& conversion.
|
deba@1933
|
157 |
|
deba@1933
|
158 |
/// This constructor initializes the iterator to be invalid.
|
deba@1933
|
159 |
/// \sa Invalid for more details.
|
deba@1933
|
160 |
ANode(Invalid) { }
|
deba@1933
|
161 |
/// Equality operator
|
deba@1933
|
162 |
|
deba@1933
|
163 |
/// Two iterators are equal if and only if they point to the
|
deba@1933
|
164 |
/// same object or both are invalid.
|
deba@1933
|
165 |
bool operator==(ANode) const { return true; }
|
deba@1933
|
166 |
|
deba@1933
|
167 |
/// Inequality operator
|
deba@1933
|
168 |
|
deba@1933
|
169 |
/// \sa operator==(ANode n)
|
deba@1933
|
170 |
///
|
deba@1933
|
171 |
bool operator!=(ANode) const { return true; }
|
deba@1933
|
172 |
|
deba@1933
|
173 |
/// Artificial ordering operator.
|
deba@1933
|
174 |
|
deba@1933
|
175 |
/// To allow the use of graph descriptors as key type in std::map or
|
deba@1933
|
176 |
/// similar associative container we require this.
|
deba@1933
|
177 |
///
|
deba@1933
|
178 |
/// \note This operator only have to define some strict ordering of
|
deba@1933
|
179 |
/// the items; this order has nothing to do with the iteration
|
deba@1933
|
180 |
/// ordering of the items.
|
deba@1933
|
181 |
bool operator<(ANode) const { return false; }
|
deba@1933
|
182 |
|
deba@1933
|
183 |
};
|
deba@1933
|
184 |
|
deba@1933
|
185 |
/// \brief The base type of bnode iterators,
|
deba@1933
|
186 |
/// or in other words, the trivial bnode iterator.
|
deba@1933
|
187 |
///
|
deba@1933
|
188 |
/// This is the base type of each anode iterator,
|
deba@1933
|
189 |
/// thus each kind of anode iterator converts to this.
|
deba@1933
|
190 |
/// More precisely each kind of node iterator should be inherited
|
deba@1933
|
191 |
/// from the trivial anode iterator. The BNode class should be used
|
deba@1933
|
192 |
/// only in special cases. Usually the Node type should be used insted
|
deba@1933
|
193 |
/// of it.
|
deba@1933
|
194 |
class BNode {
|
deba@1933
|
195 |
public:
|
deba@1933
|
196 |
/// Default constructor
|
deba@1933
|
197 |
|
deba@1933
|
198 |
/// @warning The default constructor sets the iterator
|
deba@1933
|
199 |
/// to an undefined value.
|
deba@1933
|
200 |
BNode() { }
|
deba@1933
|
201 |
/// Copy constructor.
|
deba@1933
|
202 |
|
deba@1933
|
203 |
/// Copy constructor.
|
deba@1933
|
204 |
///
|
deba@1933
|
205 |
BNode(const BNode&) { }
|
deba@1933
|
206 |
|
deba@1933
|
207 |
/// Construct the same node as BNode.
|
deba@1933
|
208 |
|
deba@1933
|
209 |
/// Construct the same node as BNode. It may throws assertion
|
deba@1933
|
210 |
/// when the given node is from the ANode set.
|
deba@1933
|
211 |
BNode(const Node&) { }
|
deba@1933
|
212 |
|
deba@1933
|
213 |
/// Invalid constructor \& conversion.
|
deba@1933
|
214 |
|
deba@1933
|
215 |
/// This constructor initializes the iterator to be invalid.
|
deba@1933
|
216 |
/// \sa Invalid for more details.
|
deba@1933
|
217 |
BNode(Invalid) { }
|
deba@1933
|
218 |
/// Equality operator
|
deba@1933
|
219 |
|
deba@1933
|
220 |
/// Two iterators are equal if and only if they point to the
|
deba@1933
|
221 |
/// same object or both are invalid.
|
deba@1933
|
222 |
bool operator==(BNode) const { return true; }
|
deba@1933
|
223 |
|
deba@1933
|
224 |
/// Inequality operator
|
deba@1933
|
225 |
|
deba@1933
|
226 |
/// \sa operator==(BNode n)
|
deba@1933
|
227 |
///
|
deba@1933
|
228 |
bool operator!=(BNode) const { return true; }
|
deba@1933
|
229 |
|
deba@1933
|
230 |
/// Artificial ordering operator.
|
deba@1933
|
231 |
|
deba@1933
|
232 |
/// To allow the use of graph descriptors as key type in std::map or
|
deba@1933
|
233 |
/// similar associative container we require this.
|
deba@1933
|
234 |
///
|
deba@1933
|
235 |
/// \note This operator only have to define some strict ordering of
|
deba@1933
|
236 |
/// the items; this order has nothing to do with the iteration
|
deba@1933
|
237 |
/// ordering of the items.
|
deba@1933
|
238 |
bool operator<(BNode) const { return false; }
|
deba@1933
|
239 |
|
deba@1933
|
240 |
};
|
deba@1911
|
241 |
|
deba@1911
|
242 |
/// This iterator goes through each node.
|
deba@1911
|
243 |
|
deba@1911
|
244 |
/// This iterator goes through each node.
|
deba@1911
|
245 |
/// Its usage is quite simple, for example you can count the number
|
deba@1911
|
246 |
/// of nodes in graph \c g of type \c Graph like this:
|
deba@1911
|
247 |
/// \code
|
deba@1911
|
248 |
/// int count=0;
|
deba@1911
|
249 |
/// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
|
deba@1911
|
250 |
/// \endcode
|
deba@1911
|
251 |
class NodeIt : public Node {
|
deba@1911
|
252 |
public:
|
deba@1911
|
253 |
/// Default constructor
|
deba@1911
|
254 |
|
deba@1911
|
255 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
256 |
/// to an undefined value.
|
deba@1911
|
257 |
NodeIt() { }
|
deba@1911
|
258 |
/// Copy constructor.
|
deba@1911
|
259 |
|
deba@1911
|
260 |
/// Copy constructor.
|
deba@1911
|
261 |
///
|
deba@1911
|
262 |
NodeIt(const NodeIt& n) : Node(n) { }
|
deba@1911
|
263 |
/// Invalid constructor \& conversion.
|
deba@1911
|
264 |
|
deba@1911
|
265 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
266 |
/// \sa Invalid for more details.
|
deba@1911
|
267 |
NodeIt(Invalid) { }
|
deba@1911
|
268 |
/// Sets the iterator to the first node.
|
deba@1911
|
269 |
|
deba@1911
|
270 |
/// Sets the iterator to the first node of \c g.
|
deba@1911
|
271 |
///
|
deba@1911
|
272 |
NodeIt(const BpUGraph&) { }
|
deba@1911
|
273 |
/// Node -> NodeIt conversion.
|
deba@1911
|
274 |
|
deba@1911
|
275 |
/// Sets the iterator to the node of \c the graph pointed by
|
deba@1911
|
276 |
/// the trivial iterator.
|
deba@1911
|
277 |
/// This feature necessitates that each time we
|
deba@1911
|
278 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1911
|
279 |
NodeIt(const BpUGraph&, const Node&) { }
|
deba@1911
|
280 |
/// Next node.
|
deba@1911
|
281 |
|
deba@1911
|
282 |
/// Assign the iterator to the next node.
|
deba@1911
|
283 |
///
|
deba@1911
|
284 |
NodeIt& operator++() { return *this; }
|
deba@1911
|
285 |
};
|
deba@1911
|
286 |
|
deba@1911
|
287 |
/// This iterator goes through each ANode.
|
deba@1911
|
288 |
|
deba@1911
|
289 |
/// This iterator goes through each ANode.
|
deba@1911
|
290 |
/// Its usage is quite simple, for example you can count the number
|
deba@1911
|
291 |
/// of nodes in graph \c g of type \c Graph like this:
|
deba@1911
|
292 |
/// \code
|
deba@1911
|
293 |
/// int count=0;
|
deba@1911
|
294 |
/// for (Graph::ANodeIt n(g); n!=INVALID; ++n) ++count;
|
deba@1911
|
295 |
/// \endcode
|
deba@1933
|
296 |
class ANodeIt : public ANode {
|
deba@1911
|
297 |
public:
|
deba@1911
|
298 |
/// Default constructor
|
deba@1911
|
299 |
|
deba@1911
|
300 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
301 |
/// to an undefined value.
|
deba@1911
|
302 |
ANodeIt() { }
|
deba@1911
|
303 |
/// Copy constructor.
|
deba@1911
|
304 |
|
deba@1911
|
305 |
/// Copy constructor.
|
deba@1911
|
306 |
///
|
deba@1911
|
307 |
ANodeIt(const ANodeIt& n) : Node(n) { }
|
deba@1911
|
308 |
/// Invalid constructor \& conversion.
|
deba@1911
|
309 |
|
deba@1911
|
310 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
311 |
/// \sa Invalid for more details.
|
deba@1911
|
312 |
ANodeIt(Invalid) { }
|
deba@1911
|
313 |
/// Sets the iterator to the first node.
|
deba@1911
|
314 |
|
deba@1911
|
315 |
/// Sets the iterator to the first node of \c g.
|
deba@1911
|
316 |
///
|
deba@1911
|
317 |
ANodeIt(const BpUGraph&) { }
|
deba@1911
|
318 |
/// Node -> ANodeIt conversion.
|
deba@1911
|
319 |
|
deba@1911
|
320 |
/// Sets the iterator to the node of \c the graph pointed by
|
deba@1911
|
321 |
/// the trivial iterator.
|
deba@1911
|
322 |
/// This feature necessitates that each time we
|
deba@1911
|
323 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1911
|
324 |
ANodeIt(const BpUGraph&, const Node&) { }
|
deba@1911
|
325 |
/// Next node.
|
deba@1911
|
326 |
|
deba@1911
|
327 |
/// Assign the iterator to the next node.
|
deba@1911
|
328 |
///
|
deba@1911
|
329 |
ANodeIt& operator++() { return *this; }
|
deba@1911
|
330 |
};
|
deba@1911
|
331 |
|
deba@1911
|
332 |
/// This iterator goes through each BNode.
|
deba@1911
|
333 |
|
deba@1911
|
334 |
/// This iterator goes through each BNode.
|
deba@1911
|
335 |
/// Its usage is quite simple, for example you can count the number
|
deba@1911
|
336 |
/// of nodes in graph \c g of type \c Graph like this:
|
deba@1911
|
337 |
/// \code
|
deba@1911
|
338 |
/// int count=0;
|
deba@1911
|
339 |
/// for (Graph::BNodeIt n(g); n!=INVALID; ++n) ++count;
|
deba@1911
|
340 |
/// \endcode
|
deba@1933
|
341 |
class BNodeIt : public BNode {
|
deba@1911
|
342 |
public:
|
deba@1911
|
343 |
/// Default constructor
|
deba@1911
|
344 |
|
deba@1911
|
345 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
346 |
/// to an undefined value.
|
deba@1911
|
347 |
BNodeIt() { }
|
deba@1911
|
348 |
/// Copy constructor.
|
deba@1911
|
349 |
|
deba@1911
|
350 |
/// Copy constructor.
|
deba@1911
|
351 |
///
|
deba@1911
|
352 |
BNodeIt(const BNodeIt& n) : Node(n) { }
|
deba@1911
|
353 |
/// Invalid constructor \& conversion.
|
deba@1911
|
354 |
|
deba@1911
|
355 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
356 |
/// \sa Invalid for more details.
|
deba@1911
|
357 |
BNodeIt(Invalid) { }
|
deba@1911
|
358 |
/// Sets the iterator to the first node.
|
deba@1911
|
359 |
|
deba@1911
|
360 |
/// Sets the iterator to the first node of \c g.
|
deba@1911
|
361 |
///
|
deba@1911
|
362 |
BNodeIt(const BpUGraph&) { }
|
deba@1911
|
363 |
/// Node -> BNodeIt conversion.
|
deba@1911
|
364 |
|
deba@1911
|
365 |
/// Sets the iterator to the node of \c the graph pointed by
|
deba@1911
|
366 |
/// the trivial iterator.
|
deba@1911
|
367 |
/// This feature necessitates that each time we
|
deba@1911
|
368 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1911
|
369 |
BNodeIt(const BpUGraph&, const Node&) { }
|
deba@1911
|
370 |
/// Next node.
|
deba@1911
|
371 |
|
deba@1911
|
372 |
/// Assign the iterator to the next node.
|
deba@1911
|
373 |
///
|
deba@1911
|
374 |
BNodeIt& operator++() { return *this; }
|
deba@1911
|
375 |
};
|
deba@1911
|
376 |
|
deba@1911
|
377 |
|
deba@1911
|
378 |
/// The base type of the undirected edge iterators.
|
deba@1911
|
379 |
|
deba@1911
|
380 |
/// The base type of the undirected edge iterators.
|
deba@1911
|
381 |
///
|
deba@1911
|
382 |
class UEdge {
|
deba@1911
|
383 |
public:
|
deba@1911
|
384 |
/// Default constructor
|
deba@1911
|
385 |
|
deba@1911
|
386 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
387 |
/// to an undefined value.
|
deba@1911
|
388 |
UEdge() { }
|
deba@1911
|
389 |
/// Copy constructor.
|
deba@1911
|
390 |
|
deba@1911
|
391 |
/// Copy constructor.
|
deba@1911
|
392 |
///
|
deba@1911
|
393 |
UEdge(const UEdge&) { }
|
deba@1911
|
394 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
395 |
|
deba@1911
|
396 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
397 |
///
|
deba@1911
|
398 |
UEdge(Invalid) { }
|
deba@1911
|
399 |
/// Equality operator
|
deba@1911
|
400 |
|
deba@1911
|
401 |
/// Two iterators are equal if and only if they point to the
|
deba@1911
|
402 |
/// same object or both are invalid.
|
deba@1911
|
403 |
bool operator==(UEdge) const { return true; }
|
deba@1911
|
404 |
/// Inequality operator
|
deba@1911
|
405 |
|
deba@1911
|
406 |
/// \sa operator==(UEdge n)
|
deba@1911
|
407 |
///
|
deba@1911
|
408 |
bool operator!=(UEdge) const { return true; }
|
deba@1911
|
409 |
|
deba@1911
|
410 |
/// Artificial ordering operator.
|
deba@1911
|
411 |
|
deba@1911
|
412 |
/// To allow the use of graph descriptors as key type in std::map or
|
deba@1911
|
413 |
/// similar associative container we require this.
|
deba@1911
|
414 |
///
|
deba@1911
|
415 |
/// \note This operator only have to define some strict ordering of
|
deba@1911
|
416 |
/// the items; this order has nothing to do with the iteration
|
deba@1911
|
417 |
/// ordering of the items.
|
deba@1911
|
418 |
///
|
deba@1911
|
419 |
/// \bug This is a technical requirement. Do we really need this?
|
deba@1911
|
420 |
bool operator<(UEdge) const { return false; }
|
deba@1911
|
421 |
};
|
deba@1911
|
422 |
|
deba@1911
|
423 |
/// This iterator goes through each undirected edge.
|
deba@1911
|
424 |
|
deba@1911
|
425 |
/// This iterator goes through each undirected edge of a graph.
|
deba@1911
|
426 |
/// Its usage is quite simple, for example you can count the number
|
deba@1911
|
427 |
/// of undirected edges in a graph \c g of type \c Graph as follows:
|
deba@1911
|
428 |
/// \code
|
deba@1911
|
429 |
/// int count=0;
|
deba@1911
|
430 |
/// for(Graph::UEdgeIt e(g); e!=INVALID; ++e) ++count;
|
deba@1911
|
431 |
/// \endcode
|
deba@1911
|
432 |
class UEdgeIt : public UEdge {
|
deba@1911
|
433 |
public:
|
deba@1911
|
434 |
/// Default constructor
|
deba@1911
|
435 |
|
deba@1911
|
436 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
437 |
/// to an undefined value.
|
deba@1911
|
438 |
UEdgeIt() { }
|
deba@1911
|
439 |
/// Copy constructor.
|
deba@1911
|
440 |
|
deba@1911
|
441 |
/// Copy constructor.
|
deba@1911
|
442 |
///
|
deba@1911
|
443 |
UEdgeIt(const UEdgeIt& e) : UEdge(e) { }
|
deba@1911
|
444 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
445 |
|
deba@1911
|
446 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
447 |
///
|
deba@1911
|
448 |
UEdgeIt(Invalid) { }
|
deba@1911
|
449 |
/// This constructor sets the iterator to the first undirected edge.
|
deba@1911
|
450 |
|
deba@1911
|
451 |
/// This constructor sets the iterator to the first undirected edge.
|
deba@1911
|
452 |
UEdgeIt(const BpUGraph&) { }
|
deba@1911
|
453 |
/// UEdge -> UEdgeIt conversion
|
deba@1911
|
454 |
|
deba@1911
|
455 |
/// Sets the iterator to the value of the trivial iterator.
|
deba@1911
|
456 |
/// This feature necessitates that each time we
|
deba@1911
|
457 |
/// iterate the undirected edge-set, the iteration order is the
|
deba@1911
|
458 |
/// same.
|
deba@1911
|
459 |
UEdgeIt(const BpUGraph&, const UEdge&) { }
|
deba@1911
|
460 |
/// Next undirected edge
|
deba@1911
|
461 |
|
deba@1911
|
462 |
/// Assign the iterator to the next undirected edge.
|
deba@1911
|
463 |
UEdgeIt& operator++() { return *this; }
|
deba@1911
|
464 |
};
|
deba@1911
|
465 |
|
deba@1911
|
466 |
/// \brief This iterator goes trough the incident undirected
|
deba@1911
|
467 |
/// edges of a node.
|
deba@1911
|
468 |
///
|
deba@1911
|
469 |
/// This iterator goes trough the incident undirected edges
|
deba@1911
|
470 |
/// of a certain node
|
deba@1911
|
471 |
/// of a graph.
|
deba@1911
|
472 |
/// Its usage is quite simple, for example you can compute the
|
deba@1911
|
473 |
/// degree (i.e. count the number
|
deba@1911
|
474 |
/// of incident edges of a node \c n
|
deba@1911
|
475 |
/// in graph \c g of type \c Graph as follows.
|
deba@1911
|
476 |
/// \code
|
deba@1911
|
477 |
/// int count=0;
|
deba@1911
|
478 |
/// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
deba@1911
|
479 |
/// \endcode
|
deba@1911
|
480 |
class IncEdgeIt : public UEdge {
|
deba@1911
|
481 |
public:
|
deba@1911
|
482 |
/// Default constructor
|
deba@1911
|
483 |
|
deba@1911
|
484 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
485 |
/// to an undefined value.
|
deba@1911
|
486 |
IncEdgeIt() { }
|
deba@1911
|
487 |
/// Copy constructor.
|
deba@1911
|
488 |
|
deba@1911
|
489 |
/// Copy constructor.
|
deba@1911
|
490 |
///
|
deba@1911
|
491 |
IncEdgeIt(const IncEdgeIt& e) : UEdge(e) { }
|
deba@1911
|
492 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
493 |
|
deba@1911
|
494 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
495 |
///
|
deba@1911
|
496 |
IncEdgeIt(Invalid) { }
|
deba@1911
|
497 |
/// This constructor sets the iterator to first incident edge.
|
deba@1911
|
498 |
|
deba@1911
|
499 |
/// This constructor set the iterator to the first incident edge of
|
deba@1911
|
500 |
/// the node.
|
deba@1911
|
501 |
IncEdgeIt(const BpUGraph&, const Node&) { }
|
deba@1911
|
502 |
/// UEdge -> IncEdgeIt conversion
|
deba@1911
|
503 |
|
deba@1911
|
504 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
deba@1911
|
505 |
/// This feature necessitates that each time we
|
deba@1911
|
506 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1911
|
507 |
IncEdgeIt(const BpUGraph&, const UEdge&) { }
|
deba@1911
|
508 |
/// Next incident edge
|
deba@1911
|
509 |
|
deba@1911
|
510 |
/// Assign the iterator to the next incident edge
|
deba@1911
|
511 |
/// of the corresponding node.
|
deba@1911
|
512 |
IncEdgeIt& operator++() { return *this; }
|
deba@1911
|
513 |
};
|
deba@1911
|
514 |
|
deba@1911
|
515 |
/// The directed edge type.
|
deba@1911
|
516 |
|
deba@1911
|
517 |
/// The directed edge type. It can be converted to the
|
deba@1911
|
518 |
/// undirected edge.
|
deba@1911
|
519 |
class Edge : public UEdge {
|
deba@1911
|
520 |
public:
|
deba@1911
|
521 |
/// Default constructor
|
deba@1911
|
522 |
|
deba@1911
|
523 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
524 |
/// to an undefined value.
|
deba@1911
|
525 |
Edge() { }
|
deba@1911
|
526 |
/// Copy constructor.
|
deba@1911
|
527 |
|
deba@1911
|
528 |
/// Copy constructor.
|
deba@1911
|
529 |
///
|
deba@1911
|
530 |
Edge(const Edge& e) : UEdge(e) { }
|
deba@1911
|
531 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
532 |
|
deba@1911
|
533 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
534 |
///
|
deba@1911
|
535 |
Edge(Invalid) { }
|
deba@1911
|
536 |
/// Equality operator
|
deba@1911
|
537 |
|
deba@1911
|
538 |
/// Two iterators are equal if and only if they point to the
|
deba@1911
|
539 |
/// same object or both are invalid.
|
deba@1911
|
540 |
bool operator==(Edge) const { return true; }
|
deba@1911
|
541 |
/// Inequality operator
|
deba@1911
|
542 |
|
deba@1911
|
543 |
/// \sa operator==(Edge n)
|
deba@1911
|
544 |
///
|
deba@1911
|
545 |
bool operator!=(Edge) const { return true; }
|
deba@1911
|
546 |
|
deba@1911
|
547 |
/// Artificial ordering operator.
|
deba@1911
|
548 |
|
deba@1911
|
549 |
/// To allow the use of graph descriptors as key type in std::map or
|
deba@1911
|
550 |
/// similar associative container we require this.
|
deba@1911
|
551 |
///
|
deba@1911
|
552 |
/// \note This operator only have to define some strict ordering of
|
deba@1911
|
553 |
/// the items; this order has nothing to do with the iteration
|
deba@1911
|
554 |
/// ordering of the items.
|
deba@1911
|
555 |
///
|
deba@1911
|
556 |
/// \bug This is a technical requirement. Do we really need this?
|
deba@1911
|
557 |
bool operator<(Edge) const { return false; }
|
deba@1911
|
558 |
|
deba@1911
|
559 |
};
|
deba@1911
|
560 |
/// This iterator goes through each directed edge.
|
deba@1911
|
561 |
|
deba@1911
|
562 |
/// This iterator goes through each edge of a graph.
|
deba@1911
|
563 |
/// Its usage is quite simple, for example you can count the number
|
deba@1911
|
564 |
/// of edges in a graph \c g of type \c Graph as follows:
|
deba@1911
|
565 |
/// \code
|
deba@1911
|
566 |
/// int count=0;
|
deba@1911
|
567 |
/// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
|
deba@1911
|
568 |
/// \endcode
|
deba@1911
|
569 |
class EdgeIt : public Edge {
|
deba@1911
|
570 |
public:
|
deba@1911
|
571 |
/// Default constructor
|
deba@1911
|
572 |
|
deba@1911
|
573 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
574 |
/// to an undefined value.
|
deba@1911
|
575 |
EdgeIt() { }
|
deba@1911
|
576 |
/// Copy constructor.
|
deba@1911
|
577 |
|
deba@1911
|
578 |
/// Copy constructor.
|
deba@1911
|
579 |
///
|
deba@1911
|
580 |
EdgeIt(const EdgeIt& e) : Edge(e) { }
|
deba@1911
|
581 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
582 |
|
deba@1911
|
583 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
584 |
///
|
deba@1911
|
585 |
EdgeIt(Invalid) { }
|
deba@1911
|
586 |
/// This constructor sets the iterator to the first edge.
|
deba@1911
|
587 |
|
deba@1911
|
588 |
/// This constructor sets the iterator to the first edge of \c g.
|
deba@1911
|
589 |
///@param g the graph
|
deba@1911
|
590 |
EdgeIt(const BpUGraph &g) { ignore_unused_variable_warning(g); }
|
deba@1911
|
591 |
/// Edge -> EdgeIt conversion
|
deba@1911
|
592 |
|
deba@1911
|
593 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
deba@1911
|
594 |
/// This feature necessitates that each time we
|
deba@1911
|
595 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1911
|
596 |
EdgeIt(const BpUGraph&, const Edge&) { }
|
deba@1911
|
597 |
///Next edge
|
deba@1911
|
598 |
|
deba@1911
|
599 |
/// Assign the iterator to the next edge.
|
deba@1911
|
600 |
EdgeIt& operator++() { return *this; }
|
deba@1911
|
601 |
};
|
deba@1911
|
602 |
|
deba@1911
|
603 |
/// This iterator goes trough the outgoing directed edges of a node.
|
deba@1911
|
604 |
|
deba@1911
|
605 |
/// This iterator goes trough the \e outgoing edges of a certain node
|
deba@1911
|
606 |
/// of a graph.
|
deba@1911
|
607 |
/// Its usage is quite simple, for example you can count the number
|
deba@1911
|
608 |
/// of outgoing edges of a node \c n
|
deba@1911
|
609 |
/// in graph \c g of type \c Graph as follows.
|
deba@1911
|
610 |
/// \code
|
deba@1911
|
611 |
/// int count=0;
|
deba@1911
|
612 |
/// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
deba@1911
|
613 |
/// \endcode
|
deba@1911
|
614 |
|
deba@1911
|
615 |
class OutEdgeIt : public Edge {
|
deba@1911
|
616 |
public:
|
deba@1911
|
617 |
/// Default constructor
|
deba@1911
|
618 |
|
deba@1911
|
619 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
620 |
/// to an undefined value.
|
deba@1911
|
621 |
OutEdgeIt() { }
|
deba@1911
|
622 |
/// Copy constructor.
|
deba@1911
|
623 |
|
deba@1911
|
624 |
/// Copy constructor.
|
deba@1911
|
625 |
///
|
deba@1911
|
626 |
OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
|
deba@1911
|
627 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
628 |
|
deba@1911
|
629 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
630 |
///
|
deba@1911
|
631 |
OutEdgeIt(Invalid) { }
|
deba@1911
|
632 |
/// This constructor sets the iterator to the first outgoing edge.
|
deba@1911
|
633 |
|
deba@1911
|
634 |
/// This constructor sets the iterator to the first outgoing edge of
|
deba@1911
|
635 |
/// the node.
|
deba@1911
|
636 |
///@param n the node
|
deba@1911
|
637 |
///@param g the graph
|
deba@1911
|
638 |
OutEdgeIt(const BpUGraph& n, const Node& g) {
|
deba@1911
|
639 |
ignore_unused_variable_warning(n);
|
deba@1911
|
640 |
ignore_unused_variable_warning(g);
|
deba@1911
|
641 |
}
|
deba@1911
|
642 |
/// Edge -> OutEdgeIt conversion
|
deba@1911
|
643 |
|
deba@1911
|
644 |
/// Sets the iterator to the value of the trivial iterator.
|
deba@1911
|
645 |
/// This feature necessitates that each time we
|
deba@1911
|
646 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1911
|
647 |
OutEdgeIt(const BpUGraph&, const Edge&) { }
|
deba@1911
|
648 |
///Next outgoing edge
|
deba@1911
|
649 |
|
deba@1911
|
650 |
/// Assign the iterator to the next
|
deba@1911
|
651 |
/// outgoing edge of the corresponding node.
|
deba@1911
|
652 |
OutEdgeIt& operator++() { return *this; }
|
deba@1911
|
653 |
};
|
deba@1911
|
654 |
|
deba@1911
|
655 |
/// This iterator goes trough the incoming directed edges of a node.
|
deba@1911
|
656 |
|
deba@1911
|
657 |
/// This iterator goes trough the \e incoming edges of a certain node
|
deba@1911
|
658 |
/// of a graph.
|
deba@1911
|
659 |
/// Its usage is quite simple, for example you can count the number
|
deba@1911
|
660 |
/// of outgoing edges of a node \c n
|
deba@1911
|
661 |
/// in graph \c g of type \c Graph as follows.
|
deba@1911
|
662 |
/// \code
|
deba@1911
|
663 |
/// int count=0;
|
deba@1911
|
664 |
/// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
|
deba@1911
|
665 |
/// \endcode
|
deba@1911
|
666 |
|
deba@1911
|
667 |
class InEdgeIt : public Edge {
|
deba@1911
|
668 |
public:
|
deba@1911
|
669 |
/// Default constructor
|
deba@1911
|
670 |
|
deba@1911
|
671 |
/// @warning The default constructor sets the iterator
|
deba@1911
|
672 |
/// to an undefined value.
|
deba@1911
|
673 |
InEdgeIt() { }
|
deba@1911
|
674 |
/// Copy constructor.
|
deba@1911
|
675 |
|
deba@1911
|
676 |
/// Copy constructor.
|
deba@1911
|
677 |
///
|
deba@1911
|
678 |
InEdgeIt(const InEdgeIt& e) : Edge(e) { }
|
deba@1911
|
679 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
680 |
|
deba@1911
|
681 |
/// Initialize the iterator to be invalid.
|
deba@1911
|
682 |
///
|
deba@1911
|
683 |
InEdgeIt(Invalid) { }
|
deba@1911
|
684 |
/// This constructor sets the iterator to first incoming edge.
|
deba@1911
|
685 |
|
deba@1911
|
686 |
/// This constructor set the iterator to the first incoming edge of
|
deba@1911
|
687 |
/// the node.
|
deba@1911
|
688 |
///@param n the node
|
deba@1911
|
689 |
///@param g the graph
|
deba@1911
|
690 |
InEdgeIt(const BpUGraph& g, const Node& n) {
|
deba@1911
|
691 |
ignore_unused_variable_warning(n);
|
deba@1911
|
692 |
ignore_unused_variable_warning(g);
|
deba@1911
|
693 |
}
|
deba@1911
|
694 |
/// Edge -> InEdgeIt conversion
|
deba@1911
|
695 |
|
deba@1911
|
696 |
/// Sets the iterator to the value of the trivial iterator \c e.
|
deba@1911
|
697 |
/// This feature necessitates that each time we
|
deba@1911
|
698 |
/// iterate the edge-set, the iteration order is the same.
|
deba@1911
|
699 |
InEdgeIt(const BpUGraph&, const Edge&) { }
|
deba@1911
|
700 |
/// Next incoming edge
|
deba@1911
|
701 |
|
deba@1911
|
702 |
/// Assign the iterator to the next inedge of the corresponding node.
|
deba@1911
|
703 |
///
|
deba@1911
|
704 |
InEdgeIt& operator++() { return *this; }
|
deba@1911
|
705 |
};
|
deba@1911
|
706 |
|
deba@1911
|
707 |
/// \brief Read write map of the nodes to type \c T.
|
deba@1911
|
708 |
///
|
deba@1911
|
709 |
/// ReadWrite map of the nodes to type \c T.
|
deba@1911
|
710 |
/// \sa Reference
|
deba@1911
|
711 |
/// \warning Making maps that can handle bool type (NodeMap<bool>)
|
deba@1911
|
712 |
/// needs some extra attention!
|
deba@1911
|
713 |
/// \todo Wrong documentation
|
deba@1911
|
714 |
template<class T>
|
deba@1911
|
715 |
class NodeMap : public ReadWriteMap< Node, T >
|
deba@1911
|
716 |
{
|
deba@1911
|
717 |
public:
|
deba@1911
|
718 |
|
deba@1911
|
719 |
///\e
|
deba@1911
|
720 |
NodeMap(const BpUGraph&) { }
|
deba@1911
|
721 |
///\e
|
deba@1911
|
722 |
NodeMap(const BpUGraph&, T) { }
|
deba@1911
|
723 |
|
deba@1911
|
724 |
///Copy constructor
|
deba@1911
|
725 |
NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
deba@1911
|
726 |
///Assignment operator
|
deba@1911
|
727 |
NodeMap& operator=(const NodeMap&) { return *this; }
|
deba@1911
|
728 |
// \todo fix this concept
|
deba@1911
|
729 |
};
|
deba@1911
|
730 |
|
deba@1911
|
731 |
/// \brief Read write map of the ANodes to type \c T.
|
deba@1911
|
732 |
///
|
deba@1911
|
733 |
/// ReadWrite map of the ANodes to type \c T.
|
deba@1911
|
734 |
/// \sa Reference
|
deba@1911
|
735 |
/// \warning Making maps that can handle bool type (NodeMap<bool>)
|
deba@1911
|
736 |
/// needs some extra attention!
|
deba@1911
|
737 |
/// \todo Wrong documentation
|
deba@1911
|
738 |
template<class T>
|
deba@1911
|
739 |
class ANodeMap : public ReadWriteMap< Node, T >
|
deba@1911
|
740 |
{
|
deba@1911
|
741 |
public:
|
deba@1911
|
742 |
|
deba@1911
|
743 |
///\e
|
deba@1911
|
744 |
ANodeMap(const BpUGraph&) { }
|
deba@1911
|
745 |
///\e
|
deba@1911
|
746 |
ANodeMap(const BpUGraph&, T) { }
|
deba@1911
|
747 |
|
deba@1911
|
748 |
///Copy constructor
|
deba@1911
|
749 |
ANodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
deba@1911
|
750 |
///Assignment operator
|
deba@1911
|
751 |
ANodeMap& operator=(const NodeMap&) { return *this; }
|
deba@1911
|
752 |
// \todo fix this concept
|
deba@1911
|
753 |
};
|
deba@1911
|
754 |
|
deba@1911
|
755 |
/// \brief Read write map of the BNodes to type \c T.
|
deba@1911
|
756 |
///
|
deba@1911
|
757 |
/// ReadWrite map of the BNodes to type \c T.
|
deba@1911
|
758 |
/// \sa Reference
|
deba@1911
|
759 |
/// \warning Making maps that can handle bool type (NodeMap<bool>)
|
deba@1911
|
760 |
/// needs some extra attention!
|
deba@1911
|
761 |
/// \todo Wrong documentation
|
deba@1911
|
762 |
template<class T>
|
deba@1911
|
763 |
class BNodeMap : public ReadWriteMap< Node, T >
|
deba@1911
|
764 |
{
|
deba@1911
|
765 |
public:
|
deba@1911
|
766 |
|
deba@1911
|
767 |
///\e
|
deba@1911
|
768 |
BNodeMap(const BpUGraph&) { }
|
deba@1911
|
769 |
///\e
|
deba@1911
|
770 |
BNodeMap(const BpUGraph&, T) { }
|
deba@1911
|
771 |
|
deba@1911
|
772 |
///Copy constructor
|
deba@1911
|
773 |
BNodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
deba@1911
|
774 |
///Assignment operator
|
deba@1911
|
775 |
BNodeMap& operator=(const NodeMap&) { return *this; }
|
deba@1911
|
776 |
// \todo fix this concept
|
deba@1911
|
777 |
};
|
deba@1911
|
778 |
|
deba@1911
|
779 |
/// \brief Read write map of the directed edges to type \c T.
|
deba@1911
|
780 |
///
|
deba@1911
|
781 |
/// Reference map of the directed edges to type \c T.
|
deba@1911
|
782 |
/// \sa Reference
|
deba@1911
|
783 |
/// \warning Making maps that can handle bool type (EdgeMap<bool>)
|
deba@1911
|
784 |
/// needs some extra attention!
|
deba@1911
|
785 |
/// \todo Wrong documentation
|
deba@1911
|
786 |
template<class T>
|
deba@1911
|
787 |
class EdgeMap : public ReadWriteMap<Edge,T>
|
deba@1911
|
788 |
{
|
deba@1911
|
789 |
public:
|
deba@1911
|
790 |
|
deba@1911
|
791 |
///\e
|
deba@1911
|
792 |
EdgeMap(const BpUGraph&) { }
|
deba@1911
|
793 |
///\e
|
deba@1911
|
794 |
EdgeMap(const BpUGraph&, T) { }
|
deba@1911
|
795 |
///Copy constructor
|
deba@1911
|
796 |
EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
|
deba@1911
|
797 |
///Assignment operator
|
deba@1911
|
798 |
EdgeMap& operator=(const EdgeMap&) { return *this; }
|
deba@1911
|
799 |
// \todo fix this concept
|
deba@1911
|
800 |
};
|
deba@1911
|
801 |
|
deba@1911
|
802 |
/// Read write map of the undirected edges to type \c T.
|
deba@1911
|
803 |
|
deba@1911
|
804 |
/// Reference map of the edges to type \c T.
|
deba@1911
|
805 |
/// \sa Reference
|
deba@1911
|
806 |
/// \warning Making maps that can handle bool type (UEdgeMap<bool>)
|
deba@1911
|
807 |
/// needs some extra attention!
|
deba@1911
|
808 |
/// \todo Wrong documentation
|
deba@1911
|
809 |
template<class T>
|
deba@1911
|
810 |
class UEdgeMap : public ReadWriteMap<UEdge,T>
|
deba@1911
|
811 |
{
|
deba@1911
|
812 |
public:
|
deba@1911
|
813 |
|
deba@1911
|
814 |
///\e
|
deba@1911
|
815 |
UEdgeMap(const BpUGraph&) { }
|
deba@1911
|
816 |
///\e
|
deba@1911
|
817 |
UEdgeMap(const BpUGraph&, T) { }
|
deba@1911
|
818 |
///Copy constructor
|
deba@1911
|
819 |
UEdgeMap(const UEdgeMap& em) : ReadWriteMap<UEdge,T>(em) {}
|
deba@1911
|
820 |
///Assignment operator
|
deba@1911
|
821 |
UEdgeMap &operator=(const UEdgeMap&) { return *this; }
|
deba@1911
|
822 |
// \todo fix this concept
|
deba@1911
|
823 |
};
|
deba@1911
|
824 |
|
deba@1911
|
825 |
/// \brief Direct the given undirected edge.
|
deba@1911
|
826 |
///
|
deba@1911
|
827 |
/// Direct the given undirected edge. The returned edge source
|
deba@1911
|
828 |
/// will be the given edge.
|
deba@1911
|
829 |
Edge direct(const UEdge&, const Node&) const {
|
deba@1911
|
830 |
return INVALID;
|
deba@1911
|
831 |
}
|
deba@1911
|
832 |
|
deba@1911
|
833 |
/// \brief Direct the given undirected edge.
|
deba@1911
|
834 |
///
|
deba@1911
|
835 |
/// Direct the given undirected edge. The returned edge source
|
deba@1911
|
836 |
/// will be the source of the undirected edge if the given bool
|
deba@1911
|
837 |
/// is true.
|
deba@1911
|
838 |
Edge direct(const UEdge&, bool) const {
|
deba@1911
|
839 |
return INVALID;
|
deba@1911
|
840 |
}
|
deba@1911
|
841 |
|
deba@1911
|
842 |
/// \brief Returns true when the given node is an ANode.
|
deba@1911
|
843 |
///
|
deba@1911
|
844 |
/// Returns true when the given node is an ANode.
|
deba@1911
|
845 |
bool aNode(Node) const { return true;}
|
deba@1911
|
846 |
|
deba@1911
|
847 |
/// \brief Returns true when the given node is an BNode.
|
deba@1911
|
848 |
///
|
deba@1911
|
849 |
/// Returns true when the given node is an BNode.
|
deba@1911
|
850 |
bool bNode(Node) const { return true;}
|
deba@1911
|
851 |
|
deba@1911
|
852 |
/// \brief Returns the edge's end node which is in the ANode set.
|
deba@1911
|
853 |
///
|
deba@1911
|
854 |
/// Returns the edge's end node which is in the ANode set.
|
deba@1911
|
855 |
Node aNode(UEdge) const { return INVALID;}
|
deba@1911
|
856 |
|
deba@1911
|
857 |
/// \brief Returns the edge's end node which is in the BNode set.
|
deba@1911
|
858 |
///
|
deba@1911
|
859 |
/// Returns the edge's end node which is in the BNode set.
|
deba@1911
|
860 |
Node bNode(UEdge) const { return INVALID;}
|
deba@1911
|
861 |
|
deba@1911
|
862 |
/// \brief Returns true if the edge has default orientation.
|
deba@1911
|
863 |
///
|
deba@1911
|
864 |
/// Returns whether the given directed edge is same orientation as
|
deba@1911
|
865 |
/// the corresponding undirected edge.
|
deba@1911
|
866 |
bool direction(Edge) const { return true; }
|
deba@1911
|
867 |
|
deba@1911
|
868 |
/// \brief Returns the opposite directed edge.
|
deba@1911
|
869 |
///
|
deba@1911
|
870 |
/// Returns the opposite directed edge.
|
deba@1911
|
871 |
Edge oppositeEdge(Edge) const { return INVALID; }
|
deba@1911
|
872 |
|
deba@1911
|
873 |
/// \brief Opposite node on an edge
|
deba@1911
|
874 |
///
|
deba@1911
|
875 |
/// \return the opposite of the given Node on the given Edge
|
deba@1911
|
876 |
Node oppositeNode(Node, UEdge) const { return INVALID; }
|
deba@1911
|
877 |
|
deba@1911
|
878 |
/// \brief First node of the undirected edge.
|
deba@1911
|
879 |
///
|
deba@1911
|
880 |
/// \return the first node of the given UEdge.
|
deba@1911
|
881 |
///
|
deba@1911
|
882 |
/// Naturally uectected edges don't have direction and thus
|
deba@1911
|
883 |
/// don't have source and target node. But we use these two methods
|
deba@1911
|
884 |
/// to query the two endnodes of the edge. The direction of the edge
|
deba@1911
|
885 |
/// which arises this way is called the inherent direction of the
|
deba@1911
|
886 |
/// undirected edge, and is used to define the "default" direction
|
deba@1911
|
887 |
/// of the directed versions of the edges.
|
deba@1911
|
888 |
/// \sa direction
|
deba@1911
|
889 |
Node source(UEdge) const { return INVALID; }
|
deba@1911
|
890 |
|
deba@1911
|
891 |
/// \brief Second node of the undirected edge.
|
deba@1911
|
892 |
Node target(UEdge) const { return INVALID; }
|
deba@1911
|
893 |
|
deba@1911
|
894 |
/// \brief Source node of the directed edge.
|
deba@1911
|
895 |
Node source(Edge) const { return INVALID; }
|
deba@1911
|
896 |
|
deba@1911
|
897 |
/// \brief Target node of the directed edge.
|
deba@1911
|
898 |
Node target(Edge) const { return INVALID; }
|
deba@1911
|
899 |
|
deba@1911
|
900 |
/// \brief Base node of the iterator
|
deba@1911
|
901 |
///
|
deba@1911
|
902 |
/// Returns the base node (the source in this case) of the iterator
|
deba@1911
|
903 |
Node baseNode(OutEdgeIt e) const {
|
deba@1911
|
904 |
return source(e);
|
deba@1911
|
905 |
}
|
deba@1911
|
906 |
|
deba@1911
|
907 |
/// \brief Running node of the iterator
|
deba@1911
|
908 |
///
|
deba@1911
|
909 |
/// Returns the running node (the target in this case) of the
|
deba@1911
|
910 |
/// iterator
|
deba@1911
|
911 |
Node runningNode(OutEdgeIt e) const {
|
deba@1911
|
912 |
return target(e);
|
deba@1911
|
913 |
}
|
deba@1911
|
914 |
|
deba@1911
|
915 |
/// \brief Base node of the iterator
|
deba@1911
|
916 |
///
|
deba@1911
|
917 |
/// Returns the base node (the target in this case) of the iterator
|
deba@1911
|
918 |
Node baseNode(InEdgeIt e) const {
|
deba@1911
|
919 |
return target(e);
|
deba@1911
|
920 |
}
|
deba@1911
|
921 |
/// \brief Running node of the iterator
|
deba@1911
|
922 |
///
|
deba@1911
|
923 |
/// Returns the running node (the source in this case) of the
|
deba@1911
|
924 |
/// iterator
|
deba@1911
|
925 |
Node runningNode(InEdgeIt e) const {
|
deba@1911
|
926 |
return source(e);
|
deba@1911
|
927 |
}
|
deba@1911
|
928 |
|
deba@1911
|
929 |
/// \brief Base node of the iterator
|
deba@1911
|
930 |
///
|
deba@1911
|
931 |
/// Returns the base node of the iterator
|
deba@1911
|
932 |
Node baseNode(IncEdgeIt) const {
|
deba@1911
|
933 |
return INVALID;
|
deba@1911
|
934 |
}
|
deba@1911
|
935 |
|
deba@1911
|
936 |
/// \brief Running node of the iterator
|
deba@1911
|
937 |
///
|
deba@1911
|
938 |
/// Returns the running node of the iterator
|
deba@1911
|
939 |
Node runningNode(IncEdgeIt) const {
|
deba@1911
|
940 |
return INVALID;
|
deba@1911
|
941 |
}
|
deba@1911
|
942 |
|
deba@1911
|
943 |
template <typename Graph>
|
deba@1911
|
944 |
struct Constraints {
|
deba@1911
|
945 |
void constraints() {
|
deba@1911
|
946 |
}
|
deba@1911
|
947 |
};
|
deba@1911
|
948 |
|
deba@1911
|
949 |
};
|
deba@1911
|
950 |
|
deba@1911
|
951 |
/// \brief An empty non-static undirected graph class.
|
deba@1911
|
952 |
///
|
deba@1911
|
953 |
/// This class provides everything that \ref BpUGraph does.
|
deba@1911
|
954 |
/// Additionally it enables building graphs from scratch.
|
deba@1911
|
955 |
class ExtendableBpUGraph : public BpUGraph {
|
deba@1911
|
956 |
public:
|
deba@1911
|
957 |
|
deba@1911
|
958 |
/// \brief Add a new ANode to the graph.
|
deba@1911
|
959 |
///
|
deba@1911
|
960 |
/// Add a new ANode to the graph.
|
deba@1911
|
961 |
/// \return the new node.
|
deba@1911
|
962 |
Node addANode();
|
deba@1911
|
963 |
|
deba@1911
|
964 |
/// \brief Add a new ANode to the graph.
|
deba@1911
|
965 |
///
|
deba@1911
|
966 |
/// Add a new ANode to the graph.
|
deba@1911
|
967 |
/// \return the new node.
|
deba@1911
|
968 |
Node addBNode();
|
deba@1911
|
969 |
|
deba@1911
|
970 |
/// \brief Add a new undirected edge to the graph.
|
deba@1911
|
971 |
///
|
deba@1911
|
972 |
/// Add a new undirected edge to the graph. One of the nodes
|
deba@1911
|
973 |
/// should be ANode and the other should be BNode.
|
deba@1911
|
974 |
/// \pre The nodes are not in the same nodeset.
|
deba@1911
|
975 |
/// \return the new edge.
|
deba@1911
|
976 |
UEdge addEdge(const Node& from, const Node& to);
|
deba@1911
|
977 |
|
deba@1911
|
978 |
/// \brief Resets the graph.
|
deba@1911
|
979 |
///
|
deba@1911
|
980 |
/// This function deletes all undirected edges and nodes of the graph.
|
deba@1911
|
981 |
/// It also frees the memory allocated to store them.
|
deba@1911
|
982 |
void clear() { }
|
deba@1911
|
983 |
|
deba@1911
|
984 |
template <typename Graph>
|
deba@1911
|
985 |
struct Constraints {
|
deba@1911
|
986 |
void constraints() {}
|
deba@1911
|
987 |
};
|
deba@1911
|
988 |
|
deba@1911
|
989 |
};
|
deba@1911
|
990 |
|
deba@1911
|
991 |
/// \brief An empty erasable undirected graph class.
|
deba@1911
|
992 |
///
|
deba@1911
|
993 |
/// This class is an extension of \ref ExtendableBpUGraph. It makes it
|
deba@1911
|
994 |
/// possible to erase undirected edges or nodes.
|
deba@1911
|
995 |
class ErasableBpUGraph : public ExtendableBpUGraph {
|
deba@1911
|
996 |
public:
|
deba@1911
|
997 |
|
deba@1911
|
998 |
/// \brief Deletes a node.
|
deba@1911
|
999 |
///
|
deba@1911
|
1000 |
/// Deletes a node.
|
deba@1911
|
1001 |
///
|
deba@1911
|
1002 |
void erase(Node) { }
|
deba@1911
|
1003 |
/// \brief Deletes an undirected edge.
|
deba@1911
|
1004 |
///
|
deba@1911
|
1005 |
/// Deletes an undirected edge.
|
deba@1911
|
1006 |
///
|
deba@1911
|
1007 |
void erase(UEdge) { }
|
deba@1911
|
1008 |
|
deba@1911
|
1009 |
template <typename Graph>
|
deba@1911
|
1010 |
struct Constraints {
|
deba@1911
|
1011 |
void constraints() {}
|
deba@1911
|
1012 |
};
|
deba@1911
|
1013 |
|
deba@1911
|
1014 |
};
|
deba@1911
|
1015 |
|
deba@1911
|
1016 |
/// @}
|
deba@1911
|
1017 |
|
deba@1911
|
1018 |
}
|
deba@1911
|
1019 |
|
deba@1911
|
1020 |
}
|
deba@1911
|
1021 |
|
deba@1911
|
1022 |
#endif
|