34 /// @{ |
34 /// @{ |
35 |
35 |
36 /**************** The full-featured graph concepts ****************/ |
36 /**************** The full-featured graph concepts ****************/ |
37 |
37 |
38 |
38 |
39 /// \brief Modular builded static graph class. |
39 /// \brief Modular static graph class. |
40 /// |
40 /// |
41 /// It should be the same as the \c StaticGraph class. |
41 /// It should be the same as the \c StaticGraph class. |
42 class _StaticGraph |
42 class _StaticGraph |
43 : virtual public BaseGraphComponent, |
43 : virtual public BaseGraphComponent, |
44 public IterableGraphComponent, public MappableGraphComponent { |
44 public IterableGraphComponent, public MappableGraphComponent { |
45 public: |
45 public: |
46 typedef BaseGraphComponent::Node Node; |
46 typedef BaseGraphComponent::Node Node; |
47 typedef BaseGraphComponent::Edge Edge; |
47 typedef BaseGraphComponent::Edge Edge; |
48 |
48 |
49 template <typename _Graph> |
49 template <typename _Graph> |
50 struct Constraints { |
50 struct Constraints { |
51 void constraints() { |
51 void constraints() { |
52 checkConcept<IterableGraphComponent, _Graph>(); |
52 checkConcept<IterableGraphComponent, _Graph>(); |
53 checkConcept<MappableGraphComponent, _Graph>(); |
53 checkConcept<MappableGraphComponent, _Graph>(); |
54 } |
54 } |
55 }; |
55 }; |
56 }; |
56 }; |
57 |
57 |
58 /// \brief Modular builded extendable graph class. |
58 /// \brief Modular extendable graph class. |
59 /// |
59 /// |
60 /// It should be the same as the \c ExtendableGraph class. |
60 /// It should be the same as the \c ExtendableGraph class. |
61 class _ExtendableGraph |
61 class _ExtendableGraph |
62 : virtual public BaseGraphComponent, public _StaticGraph, |
62 : virtual public BaseGraphComponent, public _StaticGraph, |
63 public ExtendableGraphComponent, public ClearableGraphComponent { |
63 public ExtendableGraphComponent, public ClearableGraphComponent { |
64 public: |
64 public: |
65 typedef BaseGraphComponent::Node Node; |
65 typedef BaseGraphComponent::Node Node; |
66 typedef BaseGraphComponent::Edge Edge; |
66 typedef BaseGraphComponent::Edge Edge; |
67 |
67 |
68 template <typename _Graph> |
68 template <typename _Graph> |
69 struct Constraints { |
69 struct Constraints { |
70 void constraints() { |
70 void constraints() { |
71 checkConcept<_StaticGraph, _Graph >(); |
71 checkConcept<_StaticGraph, _Graph >(); |
72 checkConcept<ExtendableGraphComponent, _Graph >(); |
72 checkConcept<ExtendableGraphComponent, _Graph >(); |
73 checkConcept<ClearableGraphComponent, _Graph >(); |
73 checkConcept<ClearableGraphComponent, _Graph >(); |
74 } |
74 } |
75 }; |
75 }; |
76 }; |
76 }; |
77 |
77 |
78 /// \brief Modular builded erasable graph class. |
78 /// \brief Modular erasable graph class. |
79 /// |
79 /// |
80 /// It should be the same as the \c ErasableGraph class. |
80 /// It should be the same as the \c ErasableGraph class. |
81 class _ErasableGraph |
81 class _ErasableGraph |
82 : virtual public BaseGraphComponent, public _ExtendableGraph, |
82 : virtual public BaseGraphComponent, public _ExtendableGraph, |
83 public ErasableGraphComponent { |
83 public ErasableGraphComponent { |
84 public: |
84 public: |
85 typedef BaseGraphComponent::Node Node; |
85 typedef BaseGraphComponent::Node Node; |
86 typedef BaseGraphComponent::Edge Edge; |
86 typedef BaseGraphComponent::Edge Edge; |
87 |
87 |
88 template <typename _Graph> |
88 template <typename _Graph> |
89 struct Constraints { |
89 struct Constraints { |
90 void constraints() { |
90 void constraints() { |
91 checkConcept<_ExtendableGraph, _Graph >(); |
91 checkConcept<_ExtendableGraph, _Graph >(); |
92 checkConcept<ErasableGraphComponent, _Graph >(); |
92 checkConcept<ErasableGraphComponent, _Graph >(); |
93 } |
93 } |
94 }; |
94 }; |
95 }; |
95 }; |
96 |
96 |
97 /// An empty static graph class. |
97 /// An empty static graph class. |
98 |
98 |
133 /// thus each kind of node iterator converts to this. |
133 /// thus each kind of node iterator converts to this. |
134 /// More precisely each kind of node iterator should be inherited |
134 /// More precisely each kind of node iterator should be inherited |
135 /// from the trivial node iterator. |
135 /// from the trivial node iterator. |
136 class Node { |
136 class Node { |
137 public: |
137 public: |
138 /// Default constructor |
138 /// Default constructor |
139 |
139 |
140 /// @warning The default constructor sets the iterator |
140 /// @warning The default constructor sets the iterator |
141 /// to an undefined value. |
141 /// to an undefined value. |
142 Node() { } |
142 Node() { } |
143 /// Copy constructor. |
143 /// Copy constructor. |
144 |
144 |
145 /// Copy constructor. |
145 /// Copy constructor. |
146 /// |
146 /// |
147 Node(const Node&) { } |
147 Node(const Node&) { } |
148 |
148 |
149 /// Invalid constructor \& conversion. |
149 /// Invalid constructor \& conversion. |
150 |
150 |
151 /// This constructor initializes the iterator to be invalid. |
151 /// This constructor initializes the iterator to be invalid. |
152 /// \sa Invalid for more details. |
152 /// \sa Invalid for more details. |
153 Node(Invalid) { } |
153 Node(Invalid) { } |
154 /// Equality operator |
154 /// Equality operator |
155 |
155 |
156 /// Two iterators are equal if and only if they point to the |
156 /// Two iterators are equal if and only if they point to the |
157 /// same object or both are invalid. |
157 /// same object or both are invalid. |
158 bool operator==(Node) const { return true; } |
158 bool operator==(Node) const { return true; } |
159 |
159 |
160 /// Inequality operator |
160 /// Inequality operator |
161 |
161 |
162 /// \sa operator==(Node n) |
162 /// \sa operator==(Node n) |
163 /// |
163 /// |
164 bool operator!=(Node) const { return true; } |
164 bool operator!=(Node) const { return true; } |
165 |
165 |
166 }; |
166 }; |
167 |
167 |
168 /// This iterator goes through each node. |
168 /// This iterator goes through each node. |
169 |
169 |
170 /// This iterator goes through each node. |
170 /// This iterator goes through each node. |
171 /// Its usage is quite simple, for example you can count the number |
171 /// Its usage is quite simple, for example you can count the number |
172 /// of nodes in graph \c g of type \c Graph like this: |
172 /// of nodes in graph \c g of type \c Graph like this: |
173 /// \code |
173 /// \code |
174 /// int count=0; |
174 /// int count=0; |
175 /// for (Graph::NodeIt n(g); n!=INVALID ++n) ++count; |
175 /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count; |
176 /// \endcode |
176 /// \endcode |
177 class NodeIt : public Node { |
177 class NodeIt : public Node { |
178 public: |
178 public: |
179 /// Default constructor |
179 /// Default constructor |
180 |
180 |
181 /// @warning The default constructor sets the iterator |
181 /// @warning The default constructor sets the iterator |
182 /// to an undefined value. |
182 /// to an undefined value. |
183 NodeIt() { } |
183 NodeIt() { } |
184 /// Copy constructor. |
184 /// Copy constructor. |
185 |
185 |
186 /// Copy constructor. |
186 /// Copy constructor. |
187 /// |
187 /// |
188 NodeIt(const NodeIt& n) : Node(n) { } |
188 NodeIt(const NodeIt& n) : Node(n) { } |
189 /// Invalid constructor \& conversion. |
189 /// Invalid constructor \& conversion. |
190 |
190 |
191 /// Initialize the iterator to be invalid. |
191 /// Initialize the iterator to be invalid. |
192 /// \sa Invalid for more details. |
192 /// \sa Invalid for more details. |
193 NodeIt(Invalid) { } |
193 NodeIt(Invalid) { } |
194 /// Sets the iterator to the first node. |
194 /// Sets the iterator to the first node. |
195 |
195 |
196 /// Sets the iterator to the first node of \c g. |
196 /// Sets the iterator to the first node of \c g. |
197 /// |
197 /// |
198 NodeIt(const StaticGraph&) { } |
198 NodeIt(const StaticGraph&) { } |
199 /// Node -> NodeIt conversion. |
199 /// Node -> NodeIt conversion. |
200 |
200 |
201 /// Sets the iterator to the node of \c g pointed by the trivial |
201 /// Sets the iterator to the node of \c g pointed by the trivial |
202 /// iterator n. |
202 /// iterator n. |
203 /// This feature necessitates that each time we |
203 /// This feature necessitates that each time we |
204 /// iterate the edge-set, the iteration order is the same. |
204 /// iterate the edge-set, the iteration order is the same. |
205 NodeIt(const StaticGraph& g, const Node& n) { } |
205 NodeIt(const StaticGraph& g, const Node& n) { } |
206 /// Next node. |
206 /// Next node. |
207 |
207 |
208 /// Assign the iterator to the next node. |
208 /// Assign the iterator to the next node. |
209 /// |
209 /// |
210 NodeIt& operator++() { return *this; } |
210 NodeIt& operator++() { return *this; } |
211 }; |
211 }; |
212 |
212 |
213 |
213 |
214 /// The base type of the edge iterators. |
214 /// The base type of the edge iterators. |
215 |
215 |
216 /// The base type of the edge iterators. |
216 /// The base type of the edge iterators. |
217 /// |
217 /// |
218 class Edge { |
218 class Edge { |
219 public: |
219 public: |
220 /// Default constructor |
220 /// Default constructor |
221 |
221 |
222 /// @warning The default constructor sets the iterator |
222 /// @warning The default constructor sets the iterator |
223 /// to an undefined value. |
223 /// to an undefined value. |
224 Edge() { } |
224 Edge() { } |
225 /// Copy constructor. |
225 /// Copy constructor. |
226 |
226 |
227 /// Copy constructor. |
227 /// Copy constructor. |
228 /// |
228 /// |
229 Edge(const Edge&) { } |
229 Edge(const Edge&) { } |
230 /// Initialize the iterator to be invalid. |
230 /// Initialize the iterator to be invalid. |
231 |
231 |
232 /// Initialize the iterator to be invalid. |
232 /// Initialize the iterator to be invalid. |
233 /// |
233 /// |
234 Edge(Invalid) { } |
234 Edge(Invalid) { } |
235 /// Equality operator |
235 /// Equality operator |
236 |
236 |
237 /// Two iterators are equal if and only if they point to the |
237 /// Two iterators are equal if and only if they point to the |
238 /// same object or both are invalid. |
238 /// same object or both are invalid. |
239 bool operator==(Edge) const { return true; } |
239 bool operator==(Edge) const { return true; } |
240 /// Inequality operator |
240 /// Inequality operator |
241 |
241 |
242 /// \sa operator==(Node n) |
242 /// \sa operator==(Node n) |
243 /// |
243 /// |
244 bool operator!=(Edge) const { return true; } |
244 bool operator!=(Edge) const { return true; } |
245 }; |
245 }; |
246 |
246 |
247 /// This iterator goes trough the outgoing edges of a node. |
247 /// This iterator goes trough the outgoing edges of a node. |
248 |
248 |
249 /// This iterator goes trough the \e outgoing edges of a certain node |
249 /// This iterator goes trough the \e outgoing edges of a certain node |
256 /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
256 /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
257 /// \endcode |
257 /// \endcode |
258 |
258 |
259 class OutEdgeIt : public Edge { |
259 class OutEdgeIt : public Edge { |
260 public: |
260 public: |
261 /// Default constructor |
261 /// Default constructor |
262 |
262 |
263 /// @warning The default constructor sets the iterator |
263 /// @warning The default constructor sets the iterator |
264 /// to an undefined value. |
264 /// to an undefined value. |
265 OutEdgeIt() { } |
265 OutEdgeIt() { } |
266 /// Copy constructor. |
266 /// Copy constructor. |
267 |
267 |
268 /// Copy constructor. |
268 /// Copy constructor. |
269 /// |
269 /// |
270 OutEdgeIt(const OutEdgeIt& e) : Edge(e) { } |
270 OutEdgeIt(const OutEdgeIt& e) : Edge(e) { } |
271 /// Initialize the iterator to be invalid. |
271 /// Initialize the iterator to be invalid. |
272 |
272 |
273 /// Initialize the iterator to be invalid. |
273 /// Initialize the iterator to be invalid. |
274 /// |
274 /// |
275 OutEdgeIt(Invalid) { } |
275 OutEdgeIt(Invalid) { } |
276 /// This constructor sets the iterator to first outgoing edge. |
276 /// This constructor sets the iterator to the first outgoing edge. |
277 |
277 |
278 /// This constructor set the iterator to the first outgoing edge of |
278 /// This constructor sets the iterator to the first outgoing edge of |
279 /// node |
279 /// the node. |
280 ///@param n the node |
280 ///@param n the node |
281 ///@param g the graph |
281 ///@param g the graph |
282 OutEdgeIt(const StaticGraph&, const Node&) { } |
282 OutEdgeIt(const StaticGraph&, const Node&) { } |
283 /// Edge -> OutEdgeIt conversion |
283 /// Edge -> OutEdgeIt conversion |
284 |
284 |
285 /// Sets the iterator to the value of the trivial iterator \c e. |
285 /// Sets the iterator to the value of the trivial iterator \c e. |
286 /// This feature necessitates that each time we |
286 /// This feature necessitates that each time we |
287 /// iterate the edge-set, the iteration order is the same. |
287 /// iterate the edge-set, the iteration order is the same. |
288 OutEdgeIt(const StaticGraph& g, const Edge& e) { } |
288 OutEdgeIt(const StaticGraph& g, const Edge& e) { } |
289 ///Next outgoing edge |
289 ///Next outgoing edge |
290 |
290 |
291 /// Assign the iterator to the next |
291 /// Assign the iterator to the next |
292 /// outgoing edge of the corresponding node. |
292 /// outgoing edge of the corresponding node. |
293 OutEdgeIt& operator++() { return *this; } |
293 OutEdgeIt& operator++() { return *this; } |
294 }; |
294 }; |
295 |
295 |
296 /// This iterator goes trough the incoming edges of a node. |
296 /// This iterator goes trough the incoming edges of a node. |
297 |
297 |
298 /// This iterator goes trough the \e incoming edges of a certain node |
298 /// This iterator goes trough the \e incoming edges of a certain node |
305 /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
305 /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
306 /// \endcode |
306 /// \endcode |
307 |
307 |
308 class InEdgeIt : public Edge { |
308 class InEdgeIt : public Edge { |
309 public: |
309 public: |
310 /// Default constructor |
310 /// Default constructor |
311 |
311 |
312 /// @warning The default constructor sets the iterator |
312 /// @warning The default constructor sets the iterator |
313 /// to an undefined value. |
313 /// to an undefined value. |
314 InEdgeIt() { } |
314 InEdgeIt() { } |
315 /// Copy constructor. |
315 /// Copy constructor. |
316 |
316 |
317 /// Copy constructor. |
317 /// Copy constructor. |
318 /// |
318 /// |
319 InEdgeIt(const InEdgeIt& e) : Edge(e) { } |
319 InEdgeIt(const InEdgeIt& e) : Edge(e) { } |
320 /// Initialize the iterator to be invalid. |
320 /// Initialize the iterator to be invalid. |
321 |
321 |
322 /// Initialize the iterator to be invalid. |
322 /// Initialize the iterator to be invalid. |
323 /// |
323 /// |
324 InEdgeIt(Invalid) { } |
324 InEdgeIt(Invalid) { } |
325 /// This constructor sets the iterator to first incoming edge. |
325 /// This constructor sets the iterator to first incoming edge. |
326 |
326 |
327 /// This constructor set the iterator to the first incoming edge of |
327 /// This constructor set the iterator to the first incoming edge of |
328 /// node |
328 /// the node. |
329 ///@param n the node |
329 ///@param n the node |
330 ///@param g the graph |
330 ///@param g the graph |
331 InEdgeIt(const StaticGraph&, const Node&) { } |
331 InEdgeIt(const StaticGraph&, const Node&) { } |
332 /// Edge -> InEdgeIt conversion |
332 /// Edge -> InEdgeIt conversion |
333 |
333 |
334 /// Sets the iterator to the value of the trivial iterator \c e. |
334 /// Sets the iterator to the value of the trivial iterator \c e. |
335 /// This feature necessitates that each time we |
335 /// This feature necessitates that each time we |
336 /// iterate the edge-set, the iteration order is the same. |
336 /// iterate the edge-set, the iteration order is the same. |
337 InEdgeIt(const StaticGraph&, const Edge&) { } |
337 InEdgeIt(const StaticGraph&, const Edge&) { } |
338 /// Next incoming edge |
338 /// Next incoming edge |
339 |
339 |
340 /// Assign the iterator to the next inedge of the corresponding node. |
340 /// Assign the iterator to the next inedge of the corresponding node. |
341 /// |
341 /// |
342 InEdgeIt& operator++() { return *this; } |
342 InEdgeIt& operator++() { return *this; } |
343 }; |
343 }; |
344 /// This iterator goes through each edge. |
344 /// This iterator goes through each edge. |
345 |
345 |
346 /// This iterator goes through each edge of a graph. |
346 /// This iterator goes through each edge of a graph. |
347 /// Its usage is quite simple, for example you can count the number |
347 /// Its usage is quite simple, for example you can count the number |
350 /// int count=0; |
350 /// int count=0; |
351 /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; |
351 /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; |
352 /// \endcode |
352 /// \endcode |
353 class EdgeIt : public Edge { |
353 class EdgeIt : public Edge { |
354 public: |
354 public: |
355 /// Default constructor |
355 /// Default constructor |
356 |
356 |
357 /// @warning The default constructor sets the iterator |
357 /// @warning The default constructor sets the iterator |
358 /// to an undefined value. |
358 /// to an undefined value. |
359 EdgeIt() { } |
359 EdgeIt() { } |
360 /// Copy constructor. |
360 /// Copy constructor. |
361 |
361 |
362 /// Copy constructor. |
362 /// Copy constructor. |
363 /// |
363 /// |
364 EdgeIt(const EdgeIt& e) : Edge(e) { } |
364 EdgeIt(const EdgeIt& e) : Edge(e) { } |
365 /// Initialize the iterator to be invalid. |
365 /// Initialize the iterator to be invalid. |
366 |
366 |
367 /// Initialize the iterator to be invalid. |
367 /// Initialize the iterator to be invalid. |
368 /// |
368 /// |
369 EdgeIt(Invalid) { } |
369 EdgeIt(Invalid) { } |
370 /// This constructor sets the iterator to first edge. |
370 /// This constructor sets the iterator to the first edge. |
371 |
371 |
372 /// This constructor set the iterator to the first edge of |
372 /// This constructor sets the iterator to the first edge of \c g. |
373 /// node |
373 ///@param g the graph |
374 ///@param g the graph |
374 EdgeIt(const StaticGraph&) { } |
375 EdgeIt(const StaticGraph&) { } |
375 /// Edge -> EdgeIt conversion |
376 /// Edge -> EdgeIt conversion |
376 |
377 |
377 /// Sets the iterator to the value of the trivial iterator \c e. |
378 /// Sets the iterator to the value of the trivial iterator \c e. |
378 /// This feature necessitates that each time we |
379 /// This feature necessitates that each time we |
379 /// iterate the edge-set, the iteration order is the same. |
380 /// iterate the edge-set, the iteration order is the same. |
380 EdgeIt(const StaticGraph&, const Edge&) { } |
381 EdgeIt(const StaticGraph&, const Edge&) { } |
381 ///Next edge |
382 ///Next edge |
382 |
383 |
383 /// Assign the iterator to the next edge. |
384 /// Assign the iterator to the next |
384 EdgeIt& operator++() { return *this; } |
385 /// edge of the corresponding node. |
|
386 EdgeIt& operator++() { return *this; } |
|
387 }; |
385 }; |
388 ///Gives back the target node of an edge. |
386 ///Gives back the target node of an edge. |
389 |
387 |
390 ///Gives back the target node of an edge. |
388 ///Gives back the target node of an edge. |
391 /// |
389 /// |
429 template<class T> |
427 template<class T> |
430 class EdgeMap : public ReadWriteMap<Edge,T> |
428 class EdgeMap : public ReadWriteMap<Edge,T> |
431 { |
429 { |
432 public: |
430 public: |
433 |
431 |
434 ///\e |
432 ///\e |
435 EdgeMap(const StaticGraph&) { } |
433 EdgeMap(const StaticGraph&) { } |
436 ///\e |
434 ///\e |
437 EdgeMap(const StaticGraph&, T) { } |
435 EdgeMap(const StaticGraph&, T) { } |
438 ///Copy constructor |
436 ///Copy constructor |
439 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
437 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
440 ///Assignment operator |
438 ///Assignment operator |
441 EdgeMap& operator=(const EdgeMap&) { return *this; } |
439 EdgeMap& operator=(const EdgeMap&) { return *this; } |
442 // \todo fix this concept |
440 // \todo fix this concept |
443 }; |
441 }; |
444 |
442 |
445 template <typename _Graph> |
443 template <typename _Graph> |
446 struct Constraints : public _StaticGraph::Constraints<_Graph> {}; |
444 struct Constraints : public _StaticGraph::Constraints<_Graph> {}; |
447 |
445 |
448 }; |
446 }; |
449 |
447 |
450 /// An empty non-static graph class. |
448 /// An empty non-static graph class. |
451 |
449 |
452 /// This class provides everything that \ref StaticGraph |
450 /// This class provides everything that \ref StaticGraph does. |
453 /// with additional functionality which enables to build a |
451 /// Additionally it enables building graphs from scratch. |
454 /// graph from scratch. |
|
455 class ExtendableGraph : public StaticGraph |
452 class ExtendableGraph : public StaticGraph |
456 { |
453 { |
457 public: |
454 public: |
458 /// Defalult constructor. |
455 /// Defalult constructor. |
459 |
456 |