158 /// \todo We may want to use the \ref concept::GraphBase "GraphBase" |
157 /// \todo We may want to use the \ref concept::GraphBase "GraphBase" |
159 /// interface here... |
158 /// interface here... |
160 /// \bug Untested ... |
159 /// \bug Untested ... |
161 template <typename Graph> |
160 template <typename Graph> |
162 typename Graph::Edge findEdge(const Graph &g, |
161 typename Graph::Edge findEdge(const Graph &g, |
163 typename Graph::Node u, typename Graph::Node v, |
162 typename Graph::Node u, typename Graph::Node v, |
164 typename Graph::Edge prev = INVALID) |
163 typename Graph::Edge prev = INVALID) |
165 { |
164 { |
166 typename Graph::OutEdgeIt e(g,prev); |
165 typename Graph::OutEdgeIt e(g,prev); |
167 // if(prev==INVALID) g.first(e,u); |
166 // if(prev==INVALID) g.first(e,u); |
168 if(prev==INVALID) e=typename Graph::OutEdgeIt(g,u); |
167 if(prev==INVALID) e=typename Graph::OutEdgeIt(g,u); |
169 else ++e; |
168 else ++e; |
223 NodeBijection& _nb, EdgeBijection& _eb) { |
222 NodeBijection& _nb, EdgeBijection& _eb) { |
224 nodeCopy(_d, _s, _nb); |
223 nodeCopy(_d, _s, _nb); |
225 edgeCopy(_d, _s, _nb, _eb); |
224 edgeCopy(_d, _s, _nb, _eb); |
226 } |
225 } |
227 |
226 |
228 template < |
227 template < |
229 typename _DestinationGraph, |
228 typename _DestinationGraph, |
230 typename _SourceGraph, |
229 typename _SourceGraph, |
231 typename _NodeBijection |
230 typename _NodeBijection |
232 =typename _SourceGraph::template NodeMap<typename _DestinationGraph::Node>, |
231 =typename _SourceGraph::template NodeMap<typename _DestinationGraph::Node>, |
233 typename _EdgeBijection |
232 typename _EdgeBijection |
234 =typename _SourceGraph::template EdgeMap<typename _DestinationGraph::Edge> |
233 = typename _SourceGraph::template EdgeMap<typename _DestinationGraph::Edge> |
235 > |
234 > |
236 class GraphCopy { |
235 class GraphCopy { |
237 public: |
236 public: |
238 |
237 |
239 typedef _DestinationGraph DestinationGraph; |
238 typedef _DestinationGraph DestinationGraph; |
240 typedef _SourceGraph SourceGraph; |
239 typedef _SourceGraph SourceGraph; |
241 |
240 |
242 typedef _NodeBijection NodeBijection; |
241 typedef _NodeBijection NodeBijection; |
243 typedef _EdgeBijection EdgeBijection; |
242 typedef _EdgeBijection EdgeBijection; |
244 |
243 |
245 protected: |
244 protected: |
246 |
245 |
247 NodeBijection node_bijection; |
246 NodeBijection node_bijection; |
248 EdgeBijection edge_bijection; |
247 EdgeBijection edge_bijection; |
249 |
248 |
250 public: |
249 public: |
251 |
250 |
252 GraphCopy(DestinationGraph& _d, const SourceGraph& _s) { |
251 GraphCopy(DestinationGraph& _d, const SourceGraph& _s) { |
253 copyGraph(_d, _s, node_bijection, edge_bijection); |
252 copyGraph(_d, _s, node_bijection, edge_bijection); |
254 } |
253 } |
255 |
254 |
256 const NodeBijection& getNodeBijection() const { |
255 const NodeBijection& getNodeBijection() const { |
257 return node_bijection; |
256 return node_bijection; |
258 } |
257 } |
259 |
258 |
260 const EdgeBijection& getEdgeBijection() const { |
259 const EdgeBijection& getEdgeBijection() const { |
261 return edge_bijection; |
260 return edge_bijection; |
262 } |
261 } |
263 |
262 |
264 }; |
263 }; |
|
264 |
|
265 |
|
266 template <typename _Graph, typename _Item> |
|
267 class ItemSetTraits { |
|
268 }; |
265 |
269 |
266 template <typename _Graph> |
270 template <typename _Graph> |
267 class GraphNodeSet { |
271 class ItemSetTraits<_Graph, typename _Graph::Node> { |
268 public: |
272 public: |
269 |
273 |
270 typedef _Graph Graph; |
274 typedef _Graph Graph; |
271 |
275 |
272 typedef typename Graph::Node Item; |
276 typedef typename Graph::Node Item; |
281 Map(const Graph& _graph) : Parent(_graph) {} |
285 Map(const Graph& _graph) : Parent(_graph) {} |
282 Map(const Graph& _graph, const Value& _value) |
286 Map(const Graph& _graph, const Value& _value) |
283 : Parent(_graph, _value) {} |
287 : Parent(_graph, _value) {} |
284 }; |
288 }; |
285 |
289 |
286 typedef IdMap<Graph, Item> IdMap; |
|
287 |
|
288 private: |
|
289 Graph* graph; |
|
290 }; |
290 }; |
291 |
291 |
292 template <typename _Graph> |
292 template <typename _Graph> |
293 class GraphEdgeSet { |
293 class ItemSetTraits<_Graph, typename _Graph::Edge> { |
294 public: |
294 public: |
295 |
295 |
296 typedef _Graph Graph; |
296 typedef _Graph Graph; |
297 |
297 |
298 typedef typename Graph::Edge Item; |
298 typedef typename Graph::Edge Item; |
307 Map(const Graph& _graph) : Parent(_graph) {} |
307 Map(const Graph& _graph) : Parent(_graph) {} |
308 Map(const Graph& _graph, const Value& _value) |
308 Map(const Graph& _graph, const Value& _value) |
309 : Parent(_graph, _value) {} |
309 : Parent(_graph, _value) {} |
310 }; |
310 }; |
311 |
311 |
312 typedef IdMap<Graph, Item> IdMap; |
312 }; |
313 |
313 |
314 private: |
314 template <typename _Graph> |
315 Graph* graph; |
315 class ItemSetTraits<_Graph, typename _Graph::UndirEdge> { |
316 }; |
316 public: |
317 |
317 |
|
318 typedef _Graph Graph; |
|
319 |
|
320 typedef typename Graph::UndirEdge Item; |
|
321 typedef typename Graph::UndirEdgeIt ItemIt; |
|
322 |
|
323 template <typename _Value> |
|
324 class Map : public Graph::template UndirEdgeMap<_Value> { |
|
325 public: |
|
326 typedef typename Graph::template UndirEdgeMap<_Value> Parent; |
|
327 typedef typename Parent::Value Value; |
|
328 |
|
329 Map(const Graph& _graph) : Parent(_graph) {} |
|
330 Map(const Graph& _graph, const Value& _value) |
|
331 : Parent(_graph, _value) {} |
|
332 }; |
|
333 |
|
334 }; |
318 |
335 |
319 /// @} |
336 /// @} |
320 |
337 |
321 } //END OF NAMESPACE LEMON |
338 } //END OF NAMESPACE LEMON |
322 |
339 |