34 /// @{ |
34 /// @{ |
35 |
35 |
36 |
36 |
37 /// Skeleton class which describes an edge with direction in \ref |
37 /// Skeleton class which describes an edge with direction in \ref |
38 /// UndirGraph "undirected graph". |
38 /// UndirGraph "undirected graph". |
39 template <typename UndirEdge> |
39 template <typename UndirGraph> |
40 class UndirGraphEdge : public UndirEdge { |
40 class UndirGraphEdge : public UndirGraph::UndirEdge { |
|
41 typedef typename UndirGraph::UndirEdge UndirEdge; |
|
42 typedef typename UndirGraph::Node Node; |
41 public: |
43 public: |
42 |
44 |
43 /// \e |
45 /// \e |
44 UndirGraphEdge() {} |
46 UndirGraphEdge() {} |
45 |
47 |
47 UndirGraphEdge(const UndirGraphEdge&) {} |
49 UndirGraphEdge(const UndirGraphEdge&) {} |
48 |
50 |
49 /// \e |
51 /// \e |
50 UndirGraphEdge(Invalid) {} |
52 UndirGraphEdge(Invalid) {} |
51 |
53 |
52 /// \brief Constructs a directed version of an undirected edge |
54 /// \brief Directed edge from undirected edge and a source node. |
53 /// |
55 /// |
54 /// \param forward If \c true the direction of the contructed edge |
56 /// Constructs a directed edge from undirected edge and a source node. |
55 /// is the same as the inherent direction of the \c undir_edge; if |
57 /// |
56 /// \c false --- the opposite. |
58 /// \note You have to specify the graph for this constructor. |
57 UndirGraphEdge(UndirEdge undir_edge, bool forward) { |
59 UndirGraphEdge(const UndirGraph &g, |
|
60 UndirEdge undir_edge, Node n) { |
58 ignore_unused_variable_warning(undir_edge); |
61 ignore_unused_variable_warning(undir_edge); |
59 ignore_unused_variable_warning(forward); |
62 ignore_unused_variable_warning(g); |
|
63 ignore_unused_variable_warning(n); |
60 } |
64 } |
61 |
65 |
62 /// \e |
66 /// \e |
63 UndirGraphEdge& operator=(UndirGraphEdge) { return *this; } |
67 UndirGraphEdge& operator=(UndirGraphEdge) { return *this; } |
64 |
68 |
71 bool operator<(UndirGraphEdge) const { return false; } |
75 bool operator<(UndirGraphEdge) const { return false; } |
72 |
76 |
73 template <typename Edge> |
77 template <typename Edge> |
74 struct Constraints { |
78 struct Constraints { |
75 void constraints() { |
79 void constraints() { |
|
80 const_constraints(); |
|
81 } |
|
82 void const_constraints() const { |
76 /// \bug This should be is_base_and_derived ... |
83 /// \bug This should be is_base_and_derived ... |
77 UndirEdge ue = e; |
84 UndirEdge ue = e; |
78 ue = e; |
85 ue = e; |
79 Edge forward(ue, true); |
86 |
80 Edge backward(ue, false); |
87 Edge e_with_source(graph,ue,n); |
81 |
88 ignore_unused_variable_warning(e_with_source); |
82 ignore_unused_variable_warning(forward); |
|
83 ignore_unused_variable_warning(backward); |
|
84 } |
89 } |
85 Edge e; |
90 Edge e; |
|
91 UndirEdge ue; |
|
92 UndirGraph graph; |
|
93 Node n; |
86 }; |
94 }; |
87 }; |
95 }; |
88 |
96 |
89 |
97 |
90 struct BaseIterableUndirGraphConcept { |
98 struct BaseIterableUndirGraphConcept { |
97 typedef typename Graph::Node Node; |
105 typedef typename Graph::Node Node; |
98 |
106 |
99 void constraints() { |
107 void constraints() { |
100 checkConcept<BaseIterableGraphComponent, Graph>(); |
108 checkConcept<BaseIterableGraphComponent, Graph>(); |
101 checkConcept<GraphItem<>, UndirEdge>(); |
109 checkConcept<GraphItem<>, UndirEdge>(); |
102 checkConcept<UndirGraphEdge<UndirEdge>, Edge>(); |
110 checkConcept<UndirGraphEdge<Graph>, Edge>(); |
103 |
111 |
104 graph.first(ue); |
112 graph.first(ue); |
105 graph.next(ue); |
113 graph.next(ue); |
106 |
114 |
107 const_constraints(); |
115 const_constraints(); |
232 /// Type describing an undirected edge |
240 /// Type describing an undirected edge |
233 typedef GraphItem<'u'> UndirEdge; |
241 typedef GraphItem<'u'> UndirEdge; |
234 |
242 |
235 /// Type describing an UndirEdge with direction |
243 /// Type describing an UndirEdge with direction |
236 #ifndef DOXYGEN |
244 #ifndef DOXYGEN |
237 typedef UndirGraphEdge<UndirEdge> Edge; |
245 typedef UndirGraphEdge<UndirGraph> Edge; |
238 #else |
246 #else |
239 typedef UndirGraphEdge Edge; |
247 typedef UndirGraphEdge Edge; |
240 #endif |
248 #endif |
241 |
249 |
242 /// Iterator type which iterates over all nodes |
250 /// Iterator type which iterates over all nodes |
428 /// developpers_interface "Developpers' interface", so it shouldn't |
436 /// developpers_interface "Developpers' interface", so it shouldn't |
429 /// be used in an end-user program. |
437 /// be used in an end-user program. |
430 void nextIn(Edge&) const {} |
438 void nextIn(Edge&) const {} |
431 |
439 |
432 |
440 |
|
441 /// Base node of the iterator |
|
442 /// |
|
443 /// Returns the base node (the source in this case) of the iterator |
|
444 Node baseNode(OutEdgeIt e) const { |
|
445 return source(e); |
|
446 } |
|
447 /// Running node of the iterator |
|
448 /// |
|
449 /// Returns the running node (the target in this case) of the |
|
450 /// iterator |
|
451 Node runningNode(OutEdgeIt e) const { |
|
452 return target(e); |
|
453 } |
|
454 |
|
455 /// Base node of the iterator |
|
456 /// |
|
457 /// Returns the base node (the target in this case) of the iterator |
|
458 Node baseNode(InEdgeIt e) const { |
|
459 return target(e); |
|
460 } |
|
461 /// Running node of the iterator |
|
462 /// |
|
463 /// Returns the running node (the source in this case) of the |
|
464 /// iterator |
|
465 Node runningNode(InEdgeIt e) const { |
|
466 return source(e); |
|
467 } |
|
468 |
|
469 /// Base node of the iterator |
|
470 /// |
|
471 /// Returns the base node of the iterator |
|
472 Node baseNode(IncEdgeIt e) const { |
|
473 return INVALID; |
|
474 } |
|
475 /// Running node of the iterator |
|
476 /// |
|
477 /// Returns the running node of the iterator |
|
478 Node runningNode(IncEdgeIt e) const { |
|
479 return INVALID; |
|
480 } |
|
481 |
|
482 |
433 template <typename Graph> |
483 template <typename Graph> |
434 struct Constraints { |
484 struct Constraints { |
435 void constraints() { |
485 void constraints() { |
436 checkConcept<BaseIterableUndirGraphConcept, Graph>(); |
486 checkConcept<BaseIterableUndirGraphConcept, Graph>(); |
437 checkConcept<IterableUndirGraphConcept, Graph>(); |
487 checkConcept<IterableUndirGraphConcept, Graph>(); |