158 EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) : |
158 EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) : |
159 GraphWrapper::EdgeMap<T>(_G.gw, a) { } |
159 GraphWrapper::EdgeMap<T>(_G.gw, a) { } |
160 }; |
160 }; |
161 }; |
161 }; |
162 |
162 |
|
163 // template<typename Graph> |
|
164 // class RevGraphWrapper |
|
165 // { |
|
166 // protected: |
|
167 // Graph* graph; |
|
168 |
|
169 // public: |
|
170 // typedef Graph BaseGraph; |
|
171 |
|
172 // typedef typename Graph::Node Node; |
|
173 // typedef typename Graph::NodeIt NodeIt; |
|
174 |
|
175 // typedef typename Graph::Edge Edge; |
|
176 // typedef typename Graph::OutEdgeIt InEdgeIt; |
|
177 // typedef typename Graph::InEdgeIt OutEdgeIt; |
|
178 // //typedef typename Graph::SymEdgeIt SymEdgeIt; |
|
179 // typedef typename Graph::EdgeIt EdgeIt; |
|
180 |
|
181 // //RevGraphWrapper() : graph(0) { } |
|
182 // RevGraphWrapper(Graph& _graph) : graph(&_graph) { } |
|
183 |
|
184 // void setGraph(Graph& _graph) { graph = &_graph; } |
|
185 // Graph& getGraph() const { return (*graph); } |
|
186 |
|
187 // template<typename I> I& first(I& i) const { return graph->first(i); } |
|
188 // template<typename I, typename P> I& first(I& i, const P& p) const { |
|
189 // return graph->first(i, p); } |
|
190 |
|
191 // template<typename I> I getNext(const I& i) const { |
|
192 // return graph->getNext(i); } |
|
193 // template<typename I> I& next(I &i) const { return graph->next(i); } |
|
194 |
|
195 // template< typename It > It first() const { |
|
196 // It e; first(e); return e; } |
|
197 |
|
198 // template< typename It > It first(const Node& v) const { |
|
199 // It e; first(e, v); return e; } |
|
200 |
|
201 // Node head(const Edge& e) const { return graph->tail(e); } |
|
202 // Node tail(const Edge& e) const { return graph->head(e); } |
|
203 |
|
204 // template<typename I> bool valid(const I& i) const |
|
205 // { return graph->valid(i); } |
|
206 |
|
207 // //template<typename I> void setInvalid(const I &i); |
|
208 // //{ return graph->setInvalid(i); } |
|
209 |
|
210 // template<typename I> Node aNode(const I& e) const { |
|
211 // return graph->aNode(e); } |
|
212 // template<typename I> Node bNode(const I& e) const { |
|
213 // return graph->bNode(e); } |
|
214 |
|
215 // Node addNode() const { return graph->addNode(); } |
|
216 // Edge addEdge(const Node& tail, const Node& head) const { |
|
217 // return graph->addEdge(tail, head); } |
|
218 |
|
219 // int nodeNum() const { return graph->nodeNum(); } |
|
220 // int edgeNum() const { return graph->edgeNum(); } |
|
221 |
|
222 // template<typename I> void erase(const I& i) const { graph->erase(i); } |
|
223 |
|
224 // void clear() const { graph->clear(); } |
|
225 |
|
226 // template<typename T> class NodeMap : public Graph::NodeMap<T> { |
|
227 // public: |
|
228 // NodeMap(const RevGraphWrapper<Graph>& _G) : |
|
229 // Graph::NodeMap<T>(_G.getGraph()) { } |
|
230 // NodeMap(const RevGraphWrapper<Graph>& _G, T a) : |
|
231 // Graph::NodeMap<T>(_G.getGraph(), a) { } |
|
232 // }; |
|
233 |
|
234 // template<typename T> class EdgeMap : public Graph::EdgeMap<T> { |
|
235 // public: |
|
236 // EdgeMap(const RevGraphWrapper<Graph>& _G) : |
|
237 // Graph::EdgeMap<T>(_G.getGraph()) { } |
|
238 // EdgeMap(const RevGraphWrapper<Graph>& _G, T a) : |
|
239 // Graph::EdgeMap<T>(_G.getGraph(), a) { } |
|
240 // }; |
|
241 // }; |
|
242 |
163 template<typename Graph> |
243 template<typename Graph> |
164 class RevGraphWrapper |
244 class RevGraphWrapper : |
165 { |
245 public GraphWrapperSkeleton< TrivGraphWrapper<Graph> > { |
166 protected: |
246 protected: |
167 Graph* graph; |
247 //Graph* graph; |
168 |
248 |
169 public: |
249 public: |
170 typedef Graph BaseGraph; |
250 //typedef Graph BaseGraph; |
171 |
251 |
172 typedef typename Graph::Node Node; |
252 //typedef typename Graph::Node Node; |
173 typedef typename Graph::NodeIt NodeIt; |
253 //typedef typename Graph::NodeIt NodeIt; |
174 |
254 |
175 typedef typename Graph::Edge Edge; |
255 //typedef typename Graph::Edge Edge; |
176 typedef typename Graph::OutEdgeIt InEdgeIt; |
256 typedef typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::OutEdgeIt InEdgeIt; |
177 typedef typename Graph::InEdgeIt OutEdgeIt; |
257 typedef typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::InEdgeIt OutEdgeIt; |
178 //typedef typename Graph::SymEdgeIt SymEdgeIt; |
258 //typedef typename Graph::SymEdgeIt SymEdgeIt; |
179 typedef typename Graph::EdgeIt EdgeIt; |
259 //typedef typename Graph::EdgeIt EdgeIt; |
180 |
260 |
181 //RevGraphWrapper() : graph(0) { } |
261 //RevGraphWrapper() : graph(0) { } |
182 RevGraphWrapper(Graph& _graph) : graph(&_graph) { } |
262 RevGraphWrapper(Graph& _graph) : GraphWrapperSkeleton< TrivGraphWrapper<Graph> >(TrivGraphWrapper<Graph>(_graph)) { } |
183 |
263 |
184 void setGraph(Graph& _graph) { graph = &_graph; } |
264 //void setGraph(Graph& _graph) { graph = &_graph; } |
185 Graph& getGraph() const { return (*graph); } |
265 //Graph& getGraph() const { return (*graph); } |
186 |
266 |
187 template<typename I> I& first(I& i) const { return graph->first(i); } |
267 //template<typename I> I& first(I& i) const { return graph->first(i); } |
188 template<typename I, typename P> I& first(I& i, const P& p) const { |
268 //template<typename I, typename P> I& first(I& i, const P& p) const { |
189 return graph->first(i, p); } |
269 // return graph->first(i, p); } |
190 |
270 |
191 template<typename I> I getNext(const I& i) const { |
271 //template<typename I> I getNext(const I& i) const { |
192 return graph->getNext(i); } |
272 // return graph->getNext(i); } |
193 template<typename I> I& next(I &i) const { return graph->next(i); } |
273 //template<typename I> I& next(I &i) const { return graph->next(i); } |
194 |
274 |
195 template< typename It > It first() const { |
275 //template< typename It > It first() const { |
196 It e; first(e); return e; } |
276 // It e; first(e); return e; } |
197 |
277 |
198 template< typename It > It first(const Node& v) const { |
278 //template< typename It > It first(const Node& v) const { |
199 It e; first(e, v); return e; } |
279 // It e; first(e, v); return e; } |
200 |
280 |
201 Node head(const Edge& e) const { return graph->tail(e); } |
281 //Node head(const Edge& e) const { return graph->tail(e); } |
202 Node tail(const Edge& e) const { return graph->head(e); } |
282 //Node tail(const Edge& e) const { return graph->head(e); } |
203 |
283 |
204 template<typename I> bool valid(const I& i) const |
284 //template<typename I> bool valid(const I& i) const |
205 { return graph->valid(i); } |
285 // { return graph->valid(i); } |
206 |
286 |
207 //template<typename I> void setInvalid(const I &i); |
287 //template<typename I> void setInvalid(const I &i); |
208 //{ return graph->setInvalid(i); } |
288 //{ return graph->setInvalid(i); } |
209 |
289 |
210 template<typename I> Node aNode(const I& e) const { |
290 //template<typename I> Node aNode(const I& e) const { |
211 return graph->aNode(e); } |
291 // return graph->aNode(e); } |
212 template<typename I> Node bNode(const I& e) const { |
292 //template<typename I> Node bNode(const I& e) const { |
213 return graph->bNode(e); } |
293 // return graph->bNode(e); } |
214 |
294 |
215 Node addNode() const { return graph->addNode(); } |
295 //Node addNode() const { return graph->addNode(); } |
216 Edge addEdge(const Node& tail, const Node& head) const { |
296 //Edge addEdge(const Node& tail, const Node& head) const { |
217 return graph->addEdge(tail, head); } |
297 // return graph->addEdge(tail, head); } |
218 |
298 |
219 int nodeNum() const { return graph->nodeNum(); } |
299 //int nodeNum() const { return graph->nodeNum(); } |
220 int edgeNum() const { return graph->edgeNum(); } |
300 //int edgeNum() const { return graph->edgeNum(); } |
221 |
301 |
222 template<typename I> void erase(const I& i) const { graph->erase(i); } |
302 //template<typename I> void erase(const I& i) const { graph->erase(i); } |
223 |
303 |
224 void clear() const { graph->clear(); } |
304 //void clear() const { graph->clear(); } |
225 |
305 |
226 template<typename T> class NodeMap : public Graph::NodeMap<T> { |
306 template<typename T> class NodeMap : |
|
307 public GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T> |
|
308 { |
227 public: |
309 public: |
228 NodeMap(const RevGraphWrapper<Graph>& _G) : |
310 NodeMap(const RevGraphWrapper<Graph>& _G) : |
229 Graph::NodeMap<T>(_G.getGraph()) { } |
311 GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T>(_G) { } |
230 NodeMap(const RevGraphWrapper<Graph>& _G, T a) : |
312 NodeMap(const RevGraphWrapper<Graph>& _G, T a) : |
231 Graph::NodeMap<T>(_G.getGraph(), a) { } |
313 GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T>(_G, a) { } |
232 }; |
314 }; |
233 |
315 |
234 template<typename T> class EdgeMap : public Graph::EdgeMap<T> { |
316 template<typename T> class EdgeMap : |
|
317 public GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T> { |
235 public: |
318 public: |
236 EdgeMap(const RevGraphWrapper<Graph>& _G) : |
319 EdgeMap(const RevGraphWrapper<Graph>& _G) : |
237 Graph::EdgeMap<T>(_G.getGraph()) { } |
320 GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T>(_G) { } |
238 EdgeMap(const RevGraphWrapper<Graph>& _G, T a) : |
321 EdgeMap(const RevGraphWrapper<Graph>& _G, T a) : |
239 Graph::EdgeMap<T>(_G.getGraph(), a) { } |
322 GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T>(_G, a) { } |
240 }; |
323 }; |
241 }; |
324 }; |
|
325 |
|
326 |
|
327 |
242 |
328 |
243 |
329 |
244 template<typename Graph> |
330 template<typename Graph> |
245 class UndirGraphWrapper { |
331 class UndirGraphWrapper { |
246 protected: |
332 protected: |