36 /**************** The full-featured graph concepts ****************/ |
36 /**************** The full-featured graph concepts ****************/ |
37 |
37 |
38 |
38 |
39 // \brief Modular 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 Graph class. |
42 class _StaticGraph |
42 class _Graph |
43 : virtual public BaseGraphComponent, |
43 : virtual public BaseGraphComponent, |
44 public IterableGraphComponent, public MappableGraphComponent { |
44 public IterableGraphComponent, public MappableGraphComponent { |
45 public: |
45 public: |
46 |
46 |
47 typedef BaseGraphComponent::Node Node; |
47 typedef BaseGraphComponent::Node Node; |
54 checkConcept<MappableGraphComponent, _Graph>(); |
54 checkConcept<MappableGraphComponent, _Graph>(); |
55 } |
55 } |
56 }; |
56 }; |
57 }; |
57 }; |
58 |
58 |
59 // \brief Modular extendable graph class. |
|
60 // |
|
61 // It should be the same as the \c ExtendableGraph class. |
|
62 class _ExtendableGraph |
|
63 : virtual public BaseGraphComponent, public _StaticGraph, |
|
64 public ExtendableGraphComponent, public ClearableGraphComponent { |
|
65 public: |
|
66 typedef BaseGraphComponent::Node Node; |
|
67 typedef BaseGraphComponent::Edge Edge; |
|
68 |
|
69 template <typename _Graph> |
|
70 struct Constraints { |
|
71 void constraints() { |
|
72 checkConcept<_StaticGraph, _Graph >(); |
|
73 checkConcept<ExtendableGraphComponent, _Graph >(); |
|
74 checkConcept<ClearableGraphComponent, _Graph >(); |
|
75 } |
|
76 }; |
|
77 }; |
|
78 |
|
79 // \brief Modular erasable graph class. |
|
80 // |
|
81 // It should be the same as the \c ErasableGraph class. |
|
82 class _ErasableGraph |
|
83 : virtual public BaseGraphComponent, public _ExtendableGraph, |
|
84 public ErasableGraphComponent { |
|
85 public: |
|
86 typedef BaseGraphComponent::Node Node; |
|
87 typedef BaseGraphComponent::Edge Edge; |
|
88 |
|
89 template <typename _Graph> |
|
90 struct Constraints { |
|
91 void constraints() { |
|
92 checkConcept<_ExtendableGraph, _Graph >(); |
|
93 checkConcept<ErasableGraphComponent, _Graph >(); |
|
94 } |
|
95 }; |
|
96 }; |
|
97 |
|
98 /// \addtogroup graph_concepts |
59 /// \addtogroup graph_concepts |
99 /// @{ |
60 /// @{ |
100 |
61 |
101 /// An empty static graph class. |
62 /// An empty graph class. |
102 |
63 |
103 /// This class provides all the common features of a graph structure, |
64 /// This class provides all the common features of a graph structure, |
104 /// however completely without implementations and real data structures |
65 /// however completely without implementations and real data structures |
105 /// behind the interface. |
66 /// behind the interface. |
106 /// All graph algorithms should compile with this class, but it will not |
67 /// All graph algorithms should compile with this class, but it will not |
114 /// like @ref ListGraph or |
75 /// like @ref ListGraph or |
115 /// @ref SmartGraph will just refer to this structure. |
76 /// @ref SmartGraph will just refer to this structure. |
116 /// |
77 /// |
117 /// \todo A pages describing the concept of concept description would |
78 /// \todo A pages describing the concept of concept description would |
118 /// be nice. |
79 /// be nice. |
119 class StaticGraph |
80 class Graph { |
120 { |
|
121 // ///Copy consructor. |
|
122 |
|
123 // ///\todo It is not clear, what we expect from a copy constructor. |
|
124 // ///E.g. How to assign the nodes/edges to each other? What about maps? |
|
125 // StaticGraph(const StaticGraph& g) { } |
|
126 public: |
81 public: |
127 ///\e |
82 ///\e |
128 |
83 |
129 /// Defalult constructor. |
84 /// Defalult constructor. |
130 |
85 |
131 /// Defalult constructor. |
86 /// Defalult constructor. |
132 /// |
87 /// |
133 StaticGraph() { } |
88 Graph() { } |
134 |
89 |
135 /// The base type of node iterators, |
90 /// The base type of node iterators, |
136 /// or in other words, the trivial node iterator. |
91 /// or in other words, the trivial node iterator. |
137 |
92 |
138 /// This is the base type of each node iterator, |
93 /// This is the base type of each node iterator, |
211 NodeIt(Invalid) { } |
166 NodeIt(Invalid) { } |
212 /// Sets the iterator to the first node. |
167 /// Sets the iterator to the first node. |
213 |
168 |
214 /// Sets the iterator to the first node of \c g. |
169 /// Sets the iterator to the first node of \c g. |
215 /// |
170 /// |
216 NodeIt(const StaticGraph&) { } |
171 NodeIt(const Graph&) { } |
217 /// Node -> NodeIt conversion. |
172 /// Node -> NodeIt conversion. |
218 |
173 |
219 /// Sets the iterator to the node of \c the graph pointed by |
174 /// Sets the iterator to the node of \c the graph pointed by |
220 /// the trivial iterator. |
175 /// the trivial iterator. |
221 /// This feature necessitates that each time we |
176 /// This feature necessitates that each time we |
222 /// iterate the edge-set, the iteration order is the same. |
177 /// iterate the edge-set, the iteration order is the same. |
223 NodeIt(const StaticGraph&, const Node&) { } |
178 NodeIt(const Graph&, const Node&) { } |
224 /// Next node. |
179 /// Next node. |
225 |
180 |
226 /// Assign the iterator to the next node. |
181 /// Assign the iterator to the next node. |
227 /// |
182 /// |
228 NodeIt& operator++() { return *this; } |
183 NodeIt& operator++() { return *this; } |
305 OutEdgeIt(Invalid) { } |
260 OutEdgeIt(Invalid) { } |
306 /// This constructor sets the iterator to the first outgoing edge. |
261 /// This constructor sets the iterator to the first outgoing edge. |
307 |
262 |
308 /// This constructor sets the iterator to the first outgoing edge of |
263 /// This constructor sets the iterator to the first outgoing edge of |
309 /// the node. |
264 /// the node. |
310 OutEdgeIt(const StaticGraph&, const Node&) { } |
265 OutEdgeIt(const Graph&, const Node&) { } |
311 /// Edge -> OutEdgeIt conversion |
266 /// Edge -> OutEdgeIt conversion |
312 |
267 |
313 /// Sets the iterator to the value of the trivial iterator. |
268 /// Sets the iterator to the value of the trivial iterator. |
314 /// This feature necessitates that each time we |
269 /// This feature necessitates that each time we |
315 /// iterate the edge-set, the iteration order is the same. |
270 /// iterate the edge-set, the iteration order is the same. |
316 OutEdgeIt(const StaticGraph&, const Edge&) { } |
271 OutEdgeIt(const Graph&, const Edge&) { } |
317 ///Next outgoing edge |
272 ///Next outgoing edge |
318 |
273 |
319 /// Assign the iterator to the next |
274 /// Assign the iterator to the next |
320 /// outgoing edge of the corresponding node. |
275 /// outgoing edge of the corresponding node. |
321 OutEdgeIt& operator++() { return *this; } |
276 OutEdgeIt& operator++() { return *this; } |
352 InEdgeIt(Invalid) { } |
307 InEdgeIt(Invalid) { } |
353 /// This constructor sets the iterator to first incoming edge. |
308 /// This constructor sets the iterator to first incoming edge. |
354 |
309 |
355 /// This constructor set the iterator to the first incoming edge of |
310 /// This constructor set the iterator to the first incoming edge of |
356 /// the node. |
311 /// the node. |
357 InEdgeIt(const StaticGraph&, const Node&) { } |
312 InEdgeIt(const Graph&, const Node&) { } |
358 /// Edge -> InEdgeIt conversion |
313 /// Edge -> InEdgeIt conversion |
359 |
314 |
360 /// Sets the iterator to the value of the trivial iterator \c e. |
315 /// Sets the iterator to the value of the trivial iterator \c e. |
361 /// This feature necessitates that each time we |
316 /// This feature necessitates that each time we |
362 /// iterate the edge-set, the iteration order is the same. |
317 /// iterate the edge-set, the iteration order is the same. |
363 InEdgeIt(const StaticGraph&, const Edge&) { } |
318 InEdgeIt(const Graph&, const Edge&) { } |
364 /// Next incoming edge |
319 /// Next incoming edge |
365 |
320 |
366 /// Assign the iterator to the next inedge of the corresponding node. |
321 /// Assign the iterator to the next inedge of the corresponding node. |
367 /// |
322 /// |
368 InEdgeIt& operator++() { return *this; } |
323 InEdgeIt& operator++() { return *this; } |
395 EdgeIt(Invalid) { } |
350 EdgeIt(Invalid) { } |
396 /// This constructor sets the iterator to the first edge. |
351 /// This constructor sets the iterator to the first edge. |
397 |
352 |
398 /// This constructor sets the iterator to the first edge of \c g. |
353 /// This constructor sets the iterator to the first edge of \c g. |
399 ///@param g the graph |
354 ///@param g the graph |
400 EdgeIt(const StaticGraph& g) { ignore_unused_variable_warning(g); } |
355 EdgeIt(const Graph& g) { ignore_unused_variable_warning(g); } |
401 /// Edge -> EdgeIt conversion |
356 /// Edge -> EdgeIt conversion |
402 |
357 |
403 /// Sets the iterator to the value of the trivial iterator \c e. |
358 /// Sets the iterator to the value of the trivial iterator \c e. |
404 /// This feature necessitates that each time we |
359 /// This feature necessitates that each time we |
405 /// iterate the edge-set, the iteration order is the same. |
360 /// iterate the edge-set, the iteration order is the same. |
406 EdgeIt(const StaticGraph&, const Edge&) { } |
361 EdgeIt(const Graph&, const Edge&) { } |
407 ///Next edge |
362 ///Next edge |
408 |
363 |
409 /// Assign the iterator to the next edge. |
364 /// Assign the iterator to the next edge. |
410 EdgeIt& operator++() { return *this; } |
365 EdgeIt& operator++() { return *this; } |
411 }; |
366 }; |
418 |
373 |
419 ///Gives back the source node of an edge. |
374 ///Gives back the source node of an edge. |
420 /// |
375 /// |
421 Node source(Edge) const { return INVALID; } |
376 Node source(Edge) const { return INVALID; } |
422 |
377 |
423 // /// Gives back the first Node in the iterating order. |
|
424 |
|
425 // /// Gives back the first Node in the iterating order. |
|
426 // /// |
|
427 void first(Node&) const {} |
378 void first(Node&) const {} |
428 |
|
429 // /// Gives back the next Node in the iterating order. |
|
430 |
|
431 // /// Gives back the next Node in the iterating order. |
|
432 // /// |
|
433 void next(Node&) const {} |
379 void next(Node&) const {} |
434 |
380 |
435 // /// Gives back the first Edge in the iterating order. |
|
436 |
|
437 // /// Gives back the first Edge in the iterating order. |
|
438 // /// |
|
439 void first(Edge&) const {} |
381 void first(Edge&) const {} |
440 // /// Gives back the next Edge in the iterating order. |
|
441 |
|
442 // /// Gives back the next Edge in the iterating order. |
|
443 // /// |
|
444 void next(Edge&) const {} |
382 void next(Edge&) const {} |
445 |
383 |
446 |
384 |
447 // /// Gives back the first of the Edges point to the given Node. |
|
448 |
|
449 // /// Gives back the first of the Edges point to the given Node. |
|
450 // /// |
|
451 void firstIn(Edge&, const Node&) const {} |
385 void firstIn(Edge&, const Node&) const {} |
452 |
|
453 // /// Gives back the next of the Edges points to the given Node. |
|
454 |
|
455 |
|
456 // /// Gives back the next of the Edges points to the given Node. |
|
457 // /// |
|
458 void nextIn(Edge&) const {} |
386 void nextIn(Edge&) const {} |
459 |
387 |
460 // /// Gives back the first of the Edges start from the given Node. |
|
461 |
|
462 // /// Gives back the first of the Edges start from the given Node. |
|
463 // /// |
|
464 void firstOut(Edge&, const Node&) const {} |
388 void firstOut(Edge&, const Node&) const {} |
465 |
|
466 // /// Gives back the next of the Edges start from the given Node. |
|
467 |
|
468 // /// Gives back the next of the Edges start from the given Node. |
|
469 // /// |
|
470 void nextOut(Edge&) const {} |
389 void nextOut(Edge&) const {} |
471 |
390 |
472 /// \brief The base node of the iterator. |
391 /// \brief The base node of the iterator. |
473 /// |
392 /// |
474 /// Gives back the base node of the iterator. |
393 /// Gives back the base node of the iterator. |
509 class NodeMap : public ReadWriteMap< Node, T > |
428 class NodeMap : public ReadWriteMap< Node, T > |
510 { |
429 { |
511 public: |
430 public: |
512 |
431 |
513 ///\e |
432 ///\e |
514 NodeMap(const StaticGraph&) { } |
433 NodeMap(const Graph&) { } |
515 ///\e |
434 ///\e |
516 NodeMap(const StaticGraph&, T) { } |
435 NodeMap(const Graph&, T) { } |
517 |
436 |
518 ///Copy constructor |
437 ///Copy constructor |
519 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
438 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
520 ///Assignment operator |
439 ///Assignment operator |
521 NodeMap& operator=(const NodeMap&) { return *this; } |
440 NodeMap& operator=(const NodeMap&) { return *this; } |
533 class EdgeMap : public ReadWriteMap<Edge,T> |
452 class EdgeMap : public ReadWriteMap<Edge,T> |
534 { |
453 { |
535 public: |
454 public: |
536 |
455 |
537 ///\e |
456 ///\e |
538 EdgeMap(const StaticGraph&) { } |
457 EdgeMap(const Graph&) { } |
539 ///\e |
458 ///\e |
540 EdgeMap(const StaticGraph&, T) { } |
459 EdgeMap(const Graph&, T) { } |
541 ///Copy constructor |
460 ///Copy constructor |
542 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
461 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
543 ///Assignment operator |
462 ///Assignment operator |
544 EdgeMap& operator=(const EdgeMap&) { return *this; } |
463 EdgeMap& operator=(const EdgeMap&) { return *this; } |
545 // \todo fix this concept |
464 // \todo fix this concept |
546 }; |
465 }; |
547 |
466 |
548 template <typename _Graph> |
467 template <typename RGraph> |
549 struct Constraints : public _StaticGraph::Constraints<_Graph> {}; |
468 struct Constraints : public _Graph::Constraints<RGraph> {}; |
550 |
|
551 }; |
|
552 |
|
553 /// An empty non-static graph class. |
|
554 |
|
555 /// This class provides everything that \ref StaticGraph does. |
|
556 /// Additionally it enables building graphs from scratch. |
|
557 class ExtendableGraph : public StaticGraph |
|
558 { |
|
559 public: |
|
560 /// Defalult constructor. |
|
561 |
|
562 /// Defalult constructor. |
|
563 /// |
|
564 ExtendableGraph() { } |
|
565 ///Add a new node to the graph. |
|
566 |
|
567 /// \return the new node. |
|
568 /// |
|
569 Node addNode() { return INVALID; } |
|
570 ///Add a new edge to the graph. |
|
571 |
|
572 ///Add a new edge to the graph with source node \c s |
|
573 ///and target node \c t. |
|
574 ///\return the new edge. |
|
575 Edge addEdge(Node, Node) { return INVALID; } |
|
576 |
|
577 /// Resets the graph. |
|
578 |
|
579 /// This function deletes all edges and nodes of the graph. |
|
580 /// It also frees the memory allocated to store them. |
|
581 /// \todo It might belong to \ref ErasableGraph. |
|
582 void clear() { } |
|
583 |
|
584 template <typename _Graph> |
|
585 struct Constraints : public _ExtendableGraph::Constraints<_Graph> {}; |
|
586 |
|
587 }; |
|
588 |
|
589 /// An empty erasable graph class. |
|
590 |
|
591 /// This class is an extension of \ref ExtendableGraph. It makes it |
|
592 /// possible to erase edges or nodes. |
|
593 class ErasableGraph : public ExtendableGraph |
|
594 { |
|
595 public: |
|
596 /// Defalult constructor. |
|
597 |
|
598 /// Defalult constructor. |
|
599 /// |
|
600 ErasableGraph() { } |
|
601 /// Deletes a node. |
|
602 |
|
603 /// Deletes node \c n node. |
|
604 /// |
|
605 void erase(Node) { } |
|
606 /// Deletes an edge. |
|
607 |
|
608 /// Deletes edge \c e edge. |
|
609 /// |
|
610 void erase(Edge) { } |
|
611 |
|
612 template <typename _Graph> |
|
613 struct Constraints : public _ErasableGraph::Constraints<_Graph> {}; |
|
614 |
469 |
615 }; |
470 }; |
616 |
471 |
617 // @} |
472 // @} |
618 } //namespace concept |
473 } //namespace concept |