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