29 |
29 |
30 namespace lemon { |
30 namespace lemon { |
31 namespace concept { |
31 namespace concept { |
32 |
32 |
33 /// \todo to be done |
33 /// \todo to be done |
34 class BaseIterableUndirGraph; |
|
35 |
34 |
36 template <typename Graph> |
|
37 struct BaseIterableUndirGraphConcept { |
35 struct BaseIterableUndirGraphConcept { |
38 typedef typename Graph::UndirEdge UndirEdge; |
|
39 typedef typename Graph::Edge Edge; |
|
40 typedef typename Graph::Node Node; |
|
41 |
36 |
42 void constraints() { |
37 template <typename Graph> |
43 checkConcept<BaseIterableGraphComponent, Graph>(); |
38 struct Constraints { |
44 checkConcept<GraphItem<'u'>, UndirEdge >(); |
|
45 |
39 |
46 /// \bug this should be base_and_derived: |
40 typedef typename Graph::UndirEdge UndirEdge; |
47 UndirEdge ue = e; |
41 typedef typename Graph::Edge Edge; |
48 ue = e; |
42 typedef typename Graph::Node Node; |
49 |
43 |
50 Node n; |
44 void constraints() { |
51 n = graph.target(ue); |
45 checkConcept<BaseIterableGraphComponent, Graph>(); |
52 n = graph.source(ue); |
46 checkConcept<GraphItem<'u'>, UndirEdge >(); |
53 |
47 |
54 graph.first(ue); |
48 /// \bug this should be base_and_derived: |
55 graph.next(ue); |
49 UndirEdge ue = e; |
56 } |
50 ue = e; |
57 const Graph &graph; |
51 |
58 Edge e; |
52 Node n; |
|
53 n = graph.target(ue); |
|
54 n = graph.source(ue); |
|
55 |
|
56 graph.first(ue); |
|
57 graph.next(ue); |
|
58 } |
|
59 const Graph &graph; |
|
60 Edge e; |
|
61 }; |
|
62 |
59 }; |
63 }; |
60 |
64 |
61 template <typename Graph> |
65 |
62 struct IterableUndirGraphConcept { |
66 struct IterableUndirGraphConcept { |
63 void constraints() { |
|
64 /// \todo we don't need the iterable component should base iterable |
|
65 // checkConcept< BaseIterableUndirGraph, Graph > (); |
|
66 checkConcept< IterableGraphComponent, Graph > (); |
|
67 |
67 |
68 typedef typename Graph::UndirEdge UndirEdge; |
68 template <typename Graph> |
69 typedef typename Graph::UndirEdgeIt UndirEdgeIt; |
69 struct Constraints { |
70 typedef typename Graph::UndirIncEdgeIt UndirIncEdgeIt; |
70 void constraints() { |
|
71 /// \todo we don't need the iterable component to be base iterable |
|
72 /// Don't we really??? |
|
73 //checkConcept< BaseIterableUndirGraphConcept, Graph > (); |
71 |
74 |
72 checkConcept< GraphIterator<Graph, UndirEdge>, UndirEdgeIt >(); |
75 checkConcept<IterableGraphComponent, Graph> (); |
73 |
76 |
74 checkConcept< |
77 typedef typename Graph::UndirEdge UndirEdge; |
75 GraphIncIterator<Graph, UndirEdge>, |
78 typedef typename Graph::UndirEdgeIt UndirEdgeIt; |
76 UndirIncEdgeIt >(); |
79 typedef typename Graph::UndirIncEdgeIt UndirIncEdgeIt; |
77 } |
80 |
|
81 checkConcept<GraphIterator<Graph, UndirEdge>, UndirEdgeIt>(); |
|
82 checkConcept<GraphIncIterator<Graph, UndirEdge>, UndirIncEdgeIt>(); |
|
83 } |
|
84 }; |
|
85 |
|
86 }; |
|
87 |
|
88 struct MappableUndirGraphConcept { |
|
89 |
|
90 template <typename Graph> |
|
91 struct Constraints { |
|
92 |
|
93 struct Dummy { |
|
94 int value; |
|
95 Dummy() : value(0) {} |
|
96 Dummy(int _v) : value(_v) {} |
|
97 }; |
|
98 |
|
99 void constraints() { |
|
100 checkConcept<MappableGraphComponent, Graph>(); |
|
101 |
|
102 typedef typename Graph::template UndirEdgeMap<int> IntMap; |
|
103 checkConcept<GraphMap<Graph, typename Graph::UndirEdge, int>, |
|
104 IntMap >(); |
|
105 |
|
106 typedef typename Graph::template UndirEdgeMap<bool> BoolMap; |
|
107 checkConcept<GraphMap<Graph, typename Graph::UndirEdge, bool>, |
|
108 BoolMap >(); |
|
109 |
|
110 typedef typename Graph::template UndirEdgeMap<Dummy> DummyMap; |
|
111 checkConcept<GraphMap<Graph, typename Graph::UndirEdge, Dummy>, |
|
112 DummyMap >(); |
|
113 } |
|
114 }; |
|
115 |
|
116 }; |
|
117 |
|
118 struct ExtendableUndirGraphConcept { |
|
119 |
|
120 template <typename Graph> |
|
121 struct Constraints { |
|
122 void constraints() { |
|
123 node_a = graph.addNode(); |
|
124 uedge = graph.addEdge(node_a, node_b); |
|
125 } |
|
126 typename Graph::Node node_a, node_b; |
|
127 typename Graph::UndirEdge uedge; |
|
128 Graph graph; |
|
129 }; |
|
130 |
|
131 }; |
|
132 |
|
133 struct ErasableUndirGraphConcept { |
|
134 |
|
135 template <typename Graph> |
|
136 struct Constraints { |
|
137 void constraints() { |
|
138 graph.erase(n); |
|
139 graph.erase(e); |
|
140 } |
|
141 Graph graph; |
|
142 typename Graph::Node n; |
|
143 typename Graph::UndirEdge e; |
|
144 }; |
|
145 |
|
146 }; |
|
147 |
|
148 class UndirGraph { |
|
149 public: |
|
150 |
|
151 template <typename Graph> |
|
152 struct Constraints { |
|
153 void constraints() { |
|
154 checkConcept<BaseIterableUndirGraphConcept, Graph>(); |
|
155 checkConcept<IterableUndirGraphConcept, Graph>(); |
|
156 checkConcept<MappableUndirGraphConcept, Graph>(); |
|
157 } |
|
158 }; |
|
159 |
|
160 }; |
|
161 |
|
162 class ExtendableUndirGraph : public UndirGraph { |
|
163 public: |
|
164 |
|
165 template <typename Graph> |
|
166 struct Constraints { |
|
167 void constraints() { |
|
168 checkConcept<BaseIterableUndirGraphConcept, Graph>(); |
|
169 checkConcept<IterableUndirGraphConcept, Graph>(); |
|
170 checkConcept<MappableUndirGraphConcept, Graph>(); |
|
171 |
|
172 checkConcept<UndirGraph, Graph>(); |
|
173 checkConcept<ExtendableUndirGraphConcept, Graph>(); |
|
174 checkConcept<ClearableGraphComponent, Graph>(); |
|
175 } |
|
176 }; |
|
177 |
|
178 }; |
|
179 |
|
180 class ErasableUndirGraph : public ExtendableUndirGraph { |
|
181 public: |
|
182 |
|
183 template <typename Graph> |
|
184 struct Constraints { |
|
185 void constraints() { |
|
186 checkConcept<ExtendableUndirGraph, Graph>(); |
|
187 checkConcept<ErasableUndirGraphConcept, Graph>(); |
|
188 } |
|
189 }; |
|
190 |
78 }; |
191 }; |
79 |
192 |
80 } |
193 } |
81 |
194 |
82 } |
195 } |