klao@962
|
1 |
/* -*- C++ -*-
|
klao@962
|
2 |
*
|
ladanyi@1435
|
3 |
* lemon/concept/undir_graph_component.h - Part of LEMON, a generic
|
klao@962
|
4 |
* C++ optimization library
|
klao@962
|
5 |
*
|
alpar@1164
|
6 |
* Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi
|
alpar@1359
|
7 |
* Kutatocsoport (Egervary Research Group on Combinatorial Optimization,
|
klao@962
|
8 |
* EGRES).
|
klao@962
|
9 |
*
|
klao@962
|
10 |
* Permission to use, modify and distribute this software is granted
|
klao@962
|
11 |
* provided that this copyright notice appears in all copies. For
|
klao@962
|
12 |
* precise terms see the accompanying LICENSE file.
|
klao@962
|
13 |
*
|
klao@962
|
14 |
* This software is provided "AS IS" with no warranty of any kind,
|
klao@962
|
15 |
* express or implied, and with no claim as to its suitability for any
|
klao@962
|
16 |
* purpose.
|
klao@962
|
17 |
*
|
klao@962
|
18 |
*/
|
klao@962
|
19 |
|
klao@1030
|
20 |
///\ingroup graph_concepts
|
klao@962
|
21 |
///\file
|
klao@962
|
22 |
///\brief Undirected graphs and components of.
|
klao@962
|
23 |
|
klao@962
|
24 |
|
klao@962
|
25 |
#ifndef LEMON_CONCEPT_UNDIR_GRAPH_H
|
klao@962
|
26 |
#define LEMON_CONCEPT_UNDIR_GRAPH_H
|
klao@962
|
27 |
|
klao@962
|
28 |
#include <lemon/concept/graph_component.h>
|
alpar@1448
|
29 |
#include <lemon/utility.h>
|
klao@962
|
30 |
|
klao@962
|
31 |
namespace lemon {
|
klao@962
|
32 |
namespace concept {
|
klao@962
|
33 |
|
klao@1030
|
34 |
/// \addtogroup graph_concepts
|
klao@1030
|
35 |
/// @{
|
klao@1030
|
36 |
|
klao@1030
|
37 |
|
klao@1030
|
38 |
/// Skeleton class which describes an edge with direction in \ref
|
klao@1030
|
39 |
/// UndirGraph "undirected graph".
|
klao@1158
|
40 |
template <typename UndirGraph>
|
klao@1158
|
41 |
class UndirGraphEdge : public UndirGraph::UndirEdge {
|
klao@1158
|
42 |
typedef typename UndirGraph::UndirEdge UndirEdge;
|
klao@1158
|
43 |
typedef typename UndirGraph::Node Node;
|
klao@1030
|
44 |
public:
|
klao@1030
|
45 |
|
klao@1030
|
46 |
/// \e
|
klao@1030
|
47 |
UndirGraphEdge() {}
|
klao@1030
|
48 |
|
klao@1030
|
49 |
/// \e
|
alpar@1367
|
50 |
UndirGraphEdge(const UndirGraphEdge& e) : UndirGraph::UndirEdge(e) {}
|
klao@1030
|
51 |
|
klao@1030
|
52 |
/// \e
|
klao@1030
|
53 |
UndirGraphEdge(Invalid) {}
|
klao@1030
|
54 |
|
klao@1158
|
55 |
/// \brief Directed edge from undirected edge and a source node.
|
klao@1030
|
56 |
///
|
klao@1158
|
57 |
/// Constructs a directed edge from undirected edge and a source node.
|
klao@1158
|
58 |
///
|
klao@1158
|
59 |
/// \note You have to specify the graph for this constructor.
|
klao@1158
|
60 |
UndirGraphEdge(const UndirGraph &g,
|
klao@1158
|
61 |
UndirEdge undir_edge, Node n) {
|
klao@1030
|
62 |
ignore_unused_variable_warning(undir_edge);
|
klao@1158
|
63 |
ignore_unused_variable_warning(g);
|
klao@1158
|
64 |
ignore_unused_variable_warning(n);
|
klao@1030
|
65 |
}
|
klao@1030
|
66 |
|
klao@1030
|
67 |
/// \e
|
klao@1030
|
68 |
UndirGraphEdge& operator=(UndirGraphEdge) { return *this; }
|
klao@1030
|
69 |
|
klao@1030
|
70 |
/// \e
|
klao@1030
|
71 |
bool operator==(UndirGraphEdge) const { return true; }
|
klao@1030
|
72 |
/// \e
|
klao@1030
|
73 |
bool operator!=(UndirGraphEdge) const { return false; }
|
klao@1030
|
74 |
|
klao@1030
|
75 |
/// \e
|
klao@1030
|
76 |
bool operator<(UndirGraphEdge) const { return false; }
|
klao@1030
|
77 |
|
klao@1030
|
78 |
template <typename Edge>
|
klao@1030
|
79 |
struct Constraints {
|
klao@1030
|
80 |
void constraints() {
|
klao@1158
|
81 |
const_constraints();
|
klao@1158
|
82 |
}
|
klao@1158
|
83 |
void const_constraints() const {
|
klao@1030
|
84 |
/// \bug This should be is_base_and_derived ...
|
klao@1030
|
85 |
UndirEdge ue = e;
|
klao@1030
|
86 |
ue = e;
|
klao@1030
|
87 |
|
klao@1158
|
88 |
Edge e_with_source(graph,ue,n);
|
klao@1158
|
89 |
ignore_unused_variable_warning(e_with_source);
|
klao@1030
|
90 |
}
|
klao@1030
|
91 |
Edge e;
|
klao@1158
|
92 |
UndirEdge ue;
|
klao@1158
|
93 |
UndirGraph graph;
|
klao@1158
|
94 |
Node n;
|
klao@1030
|
95 |
};
|
klao@1030
|
96 |
};
|
klao@1030
|
97 |
|
klao@962
|
98 |
|
klao@962
|
99 |
struct BaseIterableUndirGraphConcept {
|
deba@989
|
100 |
|
klao@1022
|
101 |
template <typename Graph>
|
klao@1022
|
102 |
struct Constraints {
|
klao@962
|
103 |
|
klao@1022
|
104 |
typedef typename Graph::UndirEdge UndirEdge;
|
klao@1022
|
105 |
typedef typename Graph::Edge Edge;
|
klao@1022
|
106 |
typedef typename Graph::Node Node;
|
klao@962
|
107 |
|
klao@1022
|
108 |
void constraints() {
|
klao@1022
|
109 |
checkConcept<BaseIterableGraphComponent, Graph>();
|
klao@1030
|
110 |
checkConcept<GraphItem<>, UndirEdge>();
|
klao@1158
|
111 |
checkConcept<UndirGraphEdge<Graph>, Edge>();
|
klao@962
|
112 |
|
klao@1030
|
113 |
graph.first(ue);
|
klao@1030
|
114 |
graph.next(ue);
|
klao@1022
|
115 |
|
klao@1030
|
116 |
const_constraints();
|
klao@1030
|
117 |
}
|
klao@1030
|
118 |
void const_constraints() {
|
klao@1022
|
119 |
Node n;
|
klao@1022
|
120 |
n = graph.target(ue);
|
klao@1022
|
121 |
n = graph.source(ue);
|
klao@1030
|
122 |
n = graph.oppositeNode(n0, ue);
|
klao@1022
|
123 |
|
klao@1030
|
124 |
bool b;
|
klao@1030
|
125 |
b = graph.forward(e);
|
klao@1030
|
126 |
ignore_unused_variable_warning(b);
|
klao@1022
|
127 |
}
|
klao@1030
|
128 |
|
klao@1030
|
129 |
Graph graph;
|
klao@1022
|
130 |
Edge e;
|
klao@1030
|
131 |
Node n0;
|
klao@1030
|
132 |
UndirEdge ue;
|
klao@1022
|
133 |
};
|
klao@1022
|
134 |
|
klao@962
|
135 |
};
|
klao@962
|
136 |
|
klao@1022
|
137 |
|
klao@962
|
138 |
struct IterableUndirGraphConcept {
|
klao@962
|
139 |
|
klao@1022
|
140 |
template <typename Graph>
|
klao@1022
|
141 |
struct Constraints {
|
klao@1022
|
142 |
void constraints() {
|
klao@1022
|
143 |
/// \todo we don't need the iterable component to be base iterable
|
klao@1022
|
144 |
/// Don't we really???
|
klao@1022
|
145 |
//checkConcept< BaseIterableUndirGraphConcept, Graph > ();
|
klao@962
|
146 |
|
klao@1022
|
147 |
checkConcept<IterableGraphComponent, Graph> ();
|
klao@1021
|
148 |
|
klao@1022
|
149 |
typedef typename Graph::UndirEdge UndirEdge;
|
klao@1022
|
150 |
typedef typename Graph::UndirEdgeIt UndirEdgeIt;
|
klao@1030
|
151 |
typedef typename Graph::IncEdgeIt IncEdgeIt;
|
klao@1022
|
152 |
|
klao@1022
|
153 |
checkConcept<GraphIterator<Graph, UndirEdge>, UndirEdgeIt>();
|
klao@1030
|
154 |
checkConcept<GraphIncIterator<Graph, UndirEdge>, IncEdgeIt>();
|
klao@1022
|
155 |
}
|
klao@1022
|
156 |
};
|
klao@1022
|
157 |
|
klao@1022
|
158 |
};
|
klao@1022
|
159 |
|
klao@1022
|
160 |
struct MappableUndirGraphConcept {
|
klao@1022
|
161 |
|
klao@1022
|
162 |
template <typename Graph>
|
klao@1022
|
163 |
struct Constraints {
|
klao@1022
|
164 |
|
klao@1022
|
165 |
struct Dummy {
|
klao@1022
|
166 |
int value;
|
klao@1022
|
167 |
Dummy() : value(0) {}
|
klao@1022
|
168 |
Dummy(int _v) : value(_v) {}
|
klao@1022
|
169 |
};
|
klao@1022
|
170 |
|
klao@1022
|
171 |
void constraints() {
|
klao@1022
|
172 |
checkConcept<MappableGraphComponent, Graph>();
|
klao@1022
|
173 |
|
klao@1022
|
174 |
typedef typename Graph::template UndirEdgeMap<int> IntMap;
|
klao@1022
|
175 |
checkConcept<GraphMap<Graph, typename Graph::UndirEdge, int>,
|
klao@1022
|
176 |
IntMap >();
|
klao@1022
|
177 |
|
klao@1022
|
178 |
typedef typename Graph::template UndirEdgeMap<bool> BoolMap;
|
klao@1022
|
179 |
checkConcept<GraphMap<Graph, typename Graph::UndirEdge, bool>,
|
klao@1022
|
180 |
BoolMap >();
|
klao@1022
|
181 |
|
klao@1022
|
182 |
typedef typename Graph::template UndirEdgeMap<Dummy> DummyMap;
|
klao@1022
|
183 |
checkConcept<GraphMap<Graph, typename Graph::UndirEdge, Dummy>,
|
klao@1022
|
184 |
DummyMap >();
|
klao@1022
|
185 |
}
|
klao@1022
|
186 |
};
|
klao@1022
|
187 |
|
klao@1022
|
188 |
};
|
klao@1022
|
189 |
|
klao@1022
|
190 |
struct ExtendableUndirGraphConcept {
|
klao@1022
|
191 |
|
klao@1022
|
192 |
template <typename Graph>
|
klao@1022
|
193 |
struct Constraints {
|
klao@1022
|
194 |
void constraints() {
|
klao@1022
|
195 |
node_a = graph.addNode();
|
klao@1022
|
196 |
uedge = graph.addEdge(node_a, node_b);
|
klao@1022
|
197 |
}
|
klao@1022
|
198 |
typename Graph::Node node_a, node_b;
|
klao@1022
|
199 |
typename Graph::UndirEdge uedge;
|
klao@1022
|
200 |
Graph graph;
|
klao@1022
|
201 |
};
|
klao@1022
|
202 |
|
klao@1022
|
203 |
};
|
klao@1022
|
204 |
|
klao@1022
|
205 |
struct ErasableUndirGraphConcept {
|
klao@1022
|
206 |
|
klao@1022
|
207 |
template <typename Graph>
|
klao@1022
|
208 |
struct Constraints {
|
klao@1022
|
209 |
void constraints() {
|
klao@1022
|
210 |
graph.erase(n);
|
klao@1022
|
211 |
graph.erase(e);
|
klao@1022
|
212 |
}
|
klao@1022
|
213 |
Graph graph;
|
klao@1022
|
214 |
typename Graph::Node n;
|
klao@1022
|
215 |
typename Graph::UndirEdge e;
|
klao@1022
|
216 |
};
|
klao@1022
|
217 |
|
klao@1022
|
218 |
};
|
klao@1022
|
219 |
|
klao@1030
|
220 |
/// Class describing the concept of Undirected Graphs.
|
klao@1030
|
221 |
|
klao@1030
|
222 |
/// This class describes the common interface of all Undirected
|
klao@1030
|
223 |
/// Graphs.
|
klao@1030
|
224 |
///
|
klao@1030
|
225 |
/// As all concept describing classes it provides only interface
|
klao@1030
|
226 |
/// without any sensible implementation. So any algorithm for
|
klao@1030
|
227 |
/// undirected graph should compile with this class, but it will not
|
klao@1030
|
228 |
/// run properly, of couse.
|
klao@1030
|
229 |
///
|
klao@1030
|
230 |
/// In LEMON undirected graphs also fulfill the concept of directed
|
klao@1030
|
231 |
/// graphs (\ref lemon::concept::Graph "Graph Concept"). For
|
klao@1030
|
232 |
/// explanation of this and more see also the page \ref undir_graphs,
|
klao@1030
|
233 |
/// a tutorial about undirected graphs.
|
klao@1030
|
234 |
|
klao@1022
|
235 |
class UndirGraph {
|
klao@1022
|
236 |
public:
|
alpar@1448
|
237 |
///\e
|
alpar@1448
|
238 |
|
alpar@1448
|
239 |
///\todo undocumented
|
alpar@1448
|
240 |
///
|
alpar@1448
|
241 |
typedef True UndirTag;
|
klao@1022
|
242 |
|
klao@1030
|
243 |
/// Type describing a node in the graph
|
klao@1030
|
244 |
typedef GraphNode Node;
|
klao@1030
|
245 |
|
klao@1030
|
246 |
/// Type describing an undirected edge
|
klao@1030
|
247 |
typedef GraphItem<'u'> UndirEdge;
|
klao@1030
|
248 |
|
klao@1030
|
249 |
/// Type describing an UndirEdge with direction
|
klao@1030
|
250 |
#ifndef DOXYGEN
|
klao@1158
|
251 |
typedef UndirGraphEdge<UndirGraph> Edge;
|
klao@1030
|
252 |
#else
|
klao@1030
|
253 |
typedef UndirGraphEdge Edge;
|
klao@1030
|
254 |
#endif
|
klao@1030
|
255 |
|
klao@1030
|
256 |
/// Iterator type which iterates over all nodes
|
klao@1030
|
257 |
#ifndef DOXYGEN
|
klao@1030
|
258 |
typedef GraphIterator<UndirGraph, Node> NodeIt;
|
klao@1030
|
259 |
#else
|
klao@1030
|
260 |
typedef GraphIterator NodeIt;
|
klao@1030
|
261 |
#endif
|
klao@1030
|
262 |
|
klao@1030
|
263 |
/// Iterator type which iterates over all undirected edges
|
klao@1030
|
264 |
#ifndef DOXYGEN
|
klao@1030
|
265 |
typedef GraphIterator<UndirGraph, UndirEdge> UndirEdgeIt;
|
klao@1030
|
266 |
#else
|
klao@1030
|
267 |
typedef GraphIterator UndirEdgeIt;
|
klao@1030
|
268 |
#endif
|
klao@1030
|
269 |
|
klao@1030
|
270 |
/// Iterator type which iterates over all directed edges.
|
klao@1030
|
271 |
|
klao@1030
|
272 |
/// Iterator type which iterates over all edges (each undirected
|
klao@1030
|
273 |
/// edge occurs twice with both directions.
|
klao@1030
|
274 |
#ifndef DOXYGEN
|
klao@1030
|
275 |
typedef GraphIterator<UndirGraph, Edge> EdgeIt;
|
klao@1030
|
276 |
#else
|
klao@1030
|
277 |
typedef GraphIterator EdgeIt;
|
klao@1030
|
278 |
#endif
|
klao@1030
|
279 |
|
klao@1030
|
280 |
|
klao@1030
|
281 |
/// Iterator of undirected edges incident to a node
|
klao@1030
|
282 |
#ifndef DOXYGEN
|
klao@1030
|
283 |
typedef GraphIncIterator<UndirGraph, UndirEdge, 'u'> IncEdgeIt;
|
klao@1030
|
284 |
#else
|
klao@1030
|
285 |
typedef GraphIncIterator IncEdgeIt;
|
klao@1030
|
286 |
#endif
|
klao@1030
|
287 |
|
klao@1030
|
288 |
/// Iterator of edges incoming to a node
|
klao@1030
|
289 |
#ifndef DOXYGEN
|
klao@1030
|
290 |
typedef GraphIncIterator<UndirGraph, Edge, 'i'> InEdgeIt;
|
klao@1030
|
291 |
#else
|
klao@1030
|
292 |
typedef GraphIncIterator InEdgeIt;
|
klao@1030
|
293 |
#endif
|
klao@1030
|
294 |
|
klao@1030
|
295 |
/// Iterator of edges outgoing from a node
|
klao@1030
|
296 |
#ifndef DOXYGEN
|
klao@1030
|
297 |
typedef GraphIncIterator<UndirGraph, Edge, 'o'> OutEdgeIt;
|
klao@1030
|
298 |
#else
|
klao@1030
|
299 |
typedef GraphIncIterator OutEdgeIt;
|
klao@1030
|
300 |
#endif
|
klao@1030
|
301 |
|
klao@1030
|
302 |
/// NodeMap template
|
klao@1030
|
303 |
#ifdef DOXYGEN
|
klao@1030
|
304 |
typedef GraphMap NodeMap<T>;
|
klao@1030
|
305 |
#endif
|
klao@1030
|
306 |
|
klao@1030
|
307 |
/// UndirEdgeMap template
|
klao@1030
|
308 |
#ifdef DOXYGEN
|
klao@1030
|
309 |
typedef GraphMap UndirEdgeMap<T>;
|
klao@1030
|
310 |
#endif
|
klao@1030
|
311 |
|
klao@1030
|
312 |
/// EdgeMap template
|
klao@1030
|
313 |
#ifdef DOXYGEN
|
klao@1030
|
314 |
typedef GraphMap EdgeMap<T>;
|
klao@1030
|
315 |
#endif
|
klao@1030
|
316 |
|
klao@1030
|
317 |
template <typename T>
|
klao@1030
|
318 |
class NodeMap : public GraphMap<UndirGraph, Node, T> {
|
klao@1030
|
319 |
typedef GraphMap<UndirGraph, Node, T> Parent;
|
klao@1030
|
320 |
public:
|
klao@1030
|
321 |
|
klao@1030
|
322 |
explicit NodeMap(const UndirGraph &g) : Parent(g) {}
|
klao@1030
|
323 |
NodeMap(const UndirGraph &g, T t) : Parent(g, t) {}
|
klao@1030
|
324 |
};
|
klao@1030
|
325 |
|
klao@1030
|
326 |
template <typename T>
|
klao@1030
|
327 |
class UndirEdgeMap : public GraphMap<UndirGraph, UndirEdge, T> {
|
klao@1030
|
328 |
typedef GraphMap<UndirGraph, UndirEdge, T> Parent;
|
klao@1030
|
329 |
public:
|
klao@1030
|
330 |
|
klao@1030
|
331 |
explicit UndirEdgeMap(const UndirGraph &g) : Parent(g) {}
|
klao@1030
|
332 |
UndirEdgeMap(const UndirGraph &g, T t) : Parent(g, t) {}
|
klao@1030
|
333 |
};
|
klao@1030
|
334 |
|
klao@1030
|
335 |
template <typename T>
|
klao@1030
|
336 |
class EdgeMap : public GraphMap<UndirGraph, Edge, T> {
|
klao@1030
|
337 |
typedef GraphMap<UndirGraph, Edge, T> Parent;
|
klao@1030
|
338 |
public:
|
klao@1030
|
339 |
|
klao@1030
|
340 |
explicit EdgeMap(const UndirGraph &g) : Parent(g) {}
|
klao@1030
|
341 |
EdgeMap(const UndirGraph &g, T t) : Parent(g, t) {}
|
klao@1030
|
342 |
};
|
klao@1030
|
343 |
|
klao@1030
|
344 |
/// Is the Edge oriented "forward"?
|
klao@1030
|
345 |
|
klao@1030
|
346 |
/// Returns whether the given directed edge is same orientation as
|
klao@1030
|
347 |
/// the corresponding undirected edge.
|
klao@1030
|
348 |
///
|
klao@1030
|
349 |
/// \todo "What does the direction of an undirected edge mean?"
|
klao@1030
|
350 |
bool forward(Edge) const { return true; }
|
klao@1030
|
351 |
|
klao@1030
|
352 |
/// Opposite node on an edge
|
klao@1030
|
353 |
|
klao@1030
|
354 |
/// \return the opposite of the given Node on the given Edge
|
klao@1030
|
355 |
///
|
klao@1030
|
356 |
/// \todo What should we do if given Node and Edge are not incident?
|
klao@1030
|
357 |
Node oppositeNode(Node, UndirEdge) const { return INVALID; }
|
klao@1030
|
358 |
|
klao@1030
|
359 |
/// First node of the undirected edge.
|
klao@1030
|
360 |
|
klao@1030
|
361 |
/// \return the first node of the given UndirEdge.
|
klao@1030
|
362 |
///
|
klao@1030
|
363 |
/// Naturally undirectected edges don't have direction and thus
|
klao@1030
|
364 |
/// don't have source and target node. But we use these two methods
|
klao@1030
|
365 |
/// to query the two endnodes of the edge. The direction of the edge
|
klao@1030
|
366 |
/// which arises this way is called the inherent direction of the
|
klao@1030
|
367 |
/// undirected edge, and is used to define the "forward" direction
|
klao@1030
|
368 |
/// of the directed versions of the edges.
|
klao@1030
|
369 |
/// \sa forward
|
klao@1030
|
370 |
Node source(UndirEdge) const { return INVALID; }
|
klao@1030
|
371 |
|
klao@1030
|
372 |
/// Second node of the undirected edge.
|
klao@1030
|
373 |
Node target(UndirEdge) const { return INVALID; }
|
klao@1030
|
374 |
|
klao@1030
|
375 |
/// Source node of the directed edge.
|
klao@1030
|
376 |
Node source(Edge) const { return INVALID; }
|
klao@1030
|
377 |
|
klao@1030
|
378 |
/// Target node of the directed edge.
|
klao@1030
|
379 |
Node target(Edge) const { return INVALID; }
|
klao@1030
|
380 |
|
klao@1030
|
381 |
/// First node of the graph
|
klao@1030
|
382 |
|
klao@1030
|
383 |
/// \note This method is part of so called \ref
|
klao@1030
|
384 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
385 |
/// be used in an end-user program.
|
klao@1030
|
386 |
void first(Node&) const {}
|
klao@1030
|
387 |
/// Next node of the graph
|
klao@1030
|
388 |
|
klao@1030
|
389 |
/// \note This method is part of so called \ref
|
klao@1030
|
390 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
391 |
/// be used in an end-user program.
|
klao@1030
|
392 |
void next(Node&) const {}
|
klao@1030
|
393 |
|
klao@1030
|
394 |
/// First undirected edge of the graph
|
klao@1030
|
395 |
|
klao@1030
|
396 |
/// \note This method is part of so called \ref
|
klao@1030
|
397 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
398 |
/// be used in an end-user program.
|
klao@1030
|
399 |
void first(UndirEdge&) const {}
|
klao@1030
|
400 |
/// Next undirected edge of the graph
|
klao@1030
|
401 |
|
klao@1030
|
402 |
/// \note This method is part of so called \ref
|
klao@1030
|
403 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
404 |
/// be used in an end-user program.
|
klao@1030
|
405 |
void next(UndirEdge&) const {}
|
klao@1030
|
406 |
|
klao@1030
|
407 |
/// First directed edge of the graph
|
klao@1030
|
408 |
|
klao@1030
|
409 |
/// \note This method is part of so called \ref
|
klao@1030
|
410 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
411 |
/// be used in an end-user program.
|
klao@1030
|
412 |
void first(Edge&) const {}
|
klao@1030
|
413 |
/// Next directed edge of the graph
|
klao@1030
|
414 |
|
klao@1030
|
415 |
/// \note This method is part of so called \ref
|
klao@1030
|
416 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
417 |
/// be used in an end-user program.
|
klao@1030
|
418 |
void next(Edge&) const {}
|
klao@1030
|
419 |
|
klao@1030
|
420 |
/// First outgoing edge from a given node
|
klao@1030
|
421 |
|
klao@1030
|
422 |
/// \note This method is part of so called \ref
|
klao@1030
|
423 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
424 |
/// be used in an end-user program.
|
klao@1030
|
425 |
void firstOut(Edge&, Node) const {}
|
klao@1030
|
426 |
/// Next outgoing edge to a node
|
klao@1030
|
427 |
|
klao@1030
|
428 |
/// \note This method is part of so called \ref
|
klao@1030
|
429 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
430 |
/// be used in an end-user program.
|
klao@1030
|
431 |
void nextOut(Edge&) const {}
|
klao@1030
|
432 |
|
klao@1030
|
433 |
/// First incoming edge to a given node
|
klao@1030
|
434 |
|
klao@1030
|
435 |
/// \note This method is part of so called \ref
|
klao@1030
|
436 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
437 |
/// be used in an end-user program.
|
klao@1030
|
438 |
void firstIn(Edge&, Node) const {}
|
klao@1030
|
439 |
/// Next incoming edge to a node
|
klao@1030
|
440 |
|
klao@1030
|
441 |
/// \note This method is part of so called \ref
|
klao@1030
|
442 |
/// developpers_interface "Developpers' interface", so it shouldn't
|
klao@1030
|
443 |
/// be used in an end-user program.
|
klao@1030
|
444 |
void nextIn(Edge&) const {}
|
klao@1030
|
445 |
|
klao@1030
|
446 |
|
klao@1158
|
447 |
/// Base node of the iterator
|
klao@1158
|
448 |
///
|
klao@1158
|
449 |
/// Returns the base node (the source in this case) of the iterator
|
klao@1158
|
450 |
Node baseNode(OutEdgeIt e) const {
|
klao@1158
|
451 |
return source(e);
|
klao@1158
|
452 |
}
|
klao@1158
|
453 |
/// Running node of the iterator
|
klao@1158
|
454 |
///
|
klao@1158
|
455 |
/// Returns the running node (the target in this case) of the
|
klao@1158
|
456 |
/// iterator
|
klao@1158
|
457 |
Node runningNode(OutEdgeIt e) const {
|
klao@1158
|
458 |
return target(e);
|
klao@1158
|
459 |
}
|
klao@1158
|
460 |
|
klao@1158
|
461 |
/// Base node of the iterator
|
klao@1158
|
462 |
///
|
klao@1158
|
463 |
/// Returns the base node (the target in this case) of the iterator
|
klao@1158
|
464 |
Node baseNode(InEdgeIt e) const {
|
klao@1158
|
465 |
return target(e);
|
klao@1158
|
466 |
}
|
klao@1158
|
467 |
/// Running node of the iterator
|
klao@1158
|
468 |
///
|
klao@1158
|
469 |
/// Returns the running node (the source in this case) of the
|
klao@1158
|
470 |
/// iterator
|
klao@1158
|
471 |
Node runningNode(InEdgeIt e) const {
|
klao@1158
|
472 |
return source(e);
|
klao@1158
|
473 |
}
|
klao@1158
|
474 |
|
klao@1158
|
475 |
/// Base node of the iterator
|
klao@1158
|
476 |
///
|
klao@1158
|
477 |
/// Returns the base node of the iterator
|
alpar@1367
|
478 |
Node baseNode(IncEdgeIt) const {
|
klao@1158
|
479 |
return INVALID;
|
klao@1158
|
480 |
}
|
klao@1158
|
481 |
/// Running node of the iterator
|
klao@1158
|
482 |
///
|
klao@1158
|
483 |
/// Returns the running node of the iterator
|
alpar@1367
|
484 |
Node runningNode(IncEdgeIt) const {
|
klao@1158
|
485 |
return INVALID;
|
klao@1158
|
486 |
}
|
klao@1158
|
487 |
|
klao@1158
|
488 |
|
klao@1022
|
489 |
template <typename Graph>
|
klao@1022
|
490 |
struct Constraints {
|
klao@1022
|
491 |
void constraints() {
|
klao@1022
|
492 |
checkConcept<BaseIterableUndirGraphConcept, Graph>();
|
klao@1022
|
493 |
checkConcept<IterableUndirGraphConcept, Graph>();
|
klao@1022
|
494 |
checkConcept<MappableUndirGraphConcept, Graph>();
|
klao@1022
|
495 |
}
|
klao@1022
|
496 |
};
|
klao@1022
|
497 |
|
klao@1022
|
498 |
};
|
klao@1022
|
499 |
|
klao@1022
|
500 |
class ExtendableUndirGraph : public UndirGraph {
|
klao@1022
|
501 |
public:
|
klao@1022
|
502 |
|
klao@1022
|
503 |
template <typename Graph>
|
klao@1022
|
504 |
struct Constraints {
|
klao@1022
|
505 |
void constraints() {
|
klao@1022
|
506 |
checkConcept<BaseIterableUndirGraphConcept, Graph>();
|
klao@1022
|
507 |
checkConcept<IterableUndirGraphConcept, Graph>();
|
klao@1022
|
508 |
checkConcept<MappableUndirGraphConcept, Graph>();
|
klao@1022
|
509 |
|
klao@1022
|
510 |
checkConcept<UndirGraph, Graph>();
|
klao@1022
|
511 |
checkConcept<ExtendableUndirGraphConcept, Graph>();
|
klao@1022
|
512 |
checkConcept<ClearableGraphComponent, Graph>();
|
klao@1022
|
513 |
}
|
klao@1022
|
514 |
};
|
klao@1022
|
515 |
|
klao@1022
|
516 |
};
|
klao@1022
|
517 |
|
klao@1022
|
518 |
class ErasableUndirGraph : public ExtendableUndirGraph {
|
klao@1022
|
519 |
public:
|
klao@1022
|
520 |
|
klao@1022
|
521 |
template <typename Graph>
|
klao@1022
|
522 |
struct Constraints {
|
klao@1022
|
523 |
void constraints() {
|
klao@1022
|
524 |
checkConcept<ExtendableUndirGraph, Graph>();
|
klao@1022
|
525 |
checkConcept<ErasableUndirGraphConcept, Graph>();
|
klao@1022
|
526 |
}
|
klao@1022
|
527 |
};
|
klao@1022
|
528 |
|
klao@962
|
529 |
};
|
klao@962
|
530 |
|
klao@1030
|
531 |
/// @}
|
klao@1030
|
532 |
|
klao@962
|
533 |
}
|
klao@962
|
534 |
|
klao@962
|
535 |
}
|
klao@962
|
536 |
|
klao@962
|
537 |
#endif
|