| 1 |
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
| 2 |
2 |
*
|
| 3 |
3 |
* This file is a part of LEMON, a generic C++ optimization library.
|
| 4 |
4 |
*
|
| 5 |
5 |
* Copyright (C) 2003-2009
|
| 6 |
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
| 7 |
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
| 8 |
8 |
*
|
| 9 |
9 |
* Permission to use, modify and distribute this software is granted
|
| 10 |
10 |
* provided that this copyright notice appears in all copies. For
|
| 11 |
11 |
* precise terms see the accompanying LICENSE file.
|
| 12 |
12 |
*
|
| 13 |
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
| 14 |
14 |
* express or implied, and with no claim as to its suitability for any
|
| 15 |
15 |
* purpose.
|
| 16 |
16 |
*
|
| 17 |
17 |
*/
|
| 18 |
18 |
|
| 19 |
19 |
#ifndef LEMON_CORE_H
|
| 20 |
20 |
#define LEMON_CORE_H
|
| 21 |
21 |
|
| 22 |
22 |
#include <vector>
|
| 23 |
23 |
#include <algorithm>
|
| 24 |
24 |
|
| 25 |
25 |
#include <lemon/config.h>
|
| 26 |
26 |
#include <lemon/bits/enable_if.h>
|
| 27 |
27 |
#include <lemon/bits/traits.h>
|
| 28 |
28 |
#include <lemon/assert.h>
|
| 29 |
29 |
|
|
30 |
// Disable the following warnings when compiling with MSVC:
|
|
31 |
// C4250: 'class1' : inherits 'class2::member' via dominance
|
|
32 |
// C4355: 'this' : used in base member initializer list
|
|
33 |
// C4503: 'function' : decorated name length exceeded, name was truncated
|
|
34 |
// C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
|
|
35 |
// C4996: 'function': was declared deprecated
|
|
36 |
#ifdef _MSC_VER
|
|
37 |
#pragma warning( disable : 4250 4355 4503 4800 4996 )
|
|
38 |
#endif
|
|
39 |
|
| 30 |
40 |
///\file
|
| 31 |
41 |
///\brief LEMON core utilities.
|
| 32 |
42 |
///
|
| 33 |
43 |
///This header file contains core utilities for LEMON.
|
| 34 |
44 |
///It is automatically included by all graph types, therefore it usually
|
| 35 |
45 |
///do not have to be included directly.
|
| 36 |
46 |
|
| 37 |
47 |
namespace lemon {
|
| 38 |
48 |
|
| 39 |
49 |
/// \brief Dummy type to make it easier to create invalid iterators.
|
| 40 |
50 |
///
|
| 41 |
51 |
/// Dummy type to make it easier to create invalid iterators.
|
| 42 |
52 |
/// See \ref INVALID for the usage.
|
| 43 |
53 |
struct Invalid {
|
| 44 |
54 |
public:
|
| 45 |
55 |
bool operator==(Invalid) { return true; }
|
| 46 |
56 |
bool operator!=(Invalid) { return false; }
|
| 47 |
57 |
bool operator< (Invalid) { return false; }
|
| 48 |
58 |
};
|
| 49 |
59 |
|
| 50 |
60 |
/// \brief Invalid iterators.
|
| 51 |
61 |
///
|
| 52 |
62 |
/// \ref Invalid is a global type that converts to each iterator
|
| 53 |
63 |
/// in such a way that the value of the target iterator will be invalid.
|
| 54 |
64 |
#ifdef LEMON_ONLY_TEMPLATES
|
| 55 |
65 |
const Invalid INVALID = Invalid();
|
| 56 |
66 |
#else
|
| 57 |
67 |
extern const Invalid INVALID;
|
| 58 |
68 |
#endif
|
| 59 |
69 |
|
| 60 |
70 |
/// \addtogroup gutils
|
| 61 |
71 |
/// @{
|
| 62 |
72 |
|
| 63 |
73 |
///Create convenience typedefs for the digraph types and iterators
|
| 64 |
74 |
|
| 65 |
75 |
///This \c \#define creates convenient type definitions for the following
|
| 66 |
76 |
///types of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
|
| 67 |
77 |
///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
|
| 68 |
78 |
///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap.
|
| 69 |
79 |
///
|
| 70 |
80 |
///\note If the graph type is a dependent type, ie. the graph type depend
|
| 71 |
81 |
///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
|
| 72 |
82 |
///macro.
|
| 73 |
83 |
#define DIGRAPH_TYPEDEFS(Digraph) \
|
| 74 |
84 |
typedef Digraph::Node Node; \
|
| 75 |
85 |
typedef Digraph::NodeIt NodeIt; \
|
| 76 |
86 |
typedef Digraph::Arc Arc; \
|
| 77 |
87 |
typedef Digraph::ArcIt ArcIt; \
|
| 78 |
88 |
typedef Digraph::InArcIt InArcIt; \
|
| 79 |
89 |
typedef Digraph::OutArcIt OutArcIt; \
|
| 80 |
90 |
typedef Digraph::NodeMap<bool> BoolNodeMap; \
|
| 81 |
91 |
typedef Digraph::NodeMap<int> IntNodeMap; \
|
| 82 |
92 |
typedef Digraph::NodeMap<double> DoubleNodeMap; \
|
| 83 |
93 |
typedef Digraph::ArcMap<bool> BoolArcMap; \
|
| 84 |
94 |
typedef Digraph::ArcMap<int> IntArcMap; \
|
| 85 |
95 |
typedef Digraph::ArcMap<double> DoubleArcMap
|
| 86 |
96 |
|
| 87 |
97 |
///Create convenience typedefs for the digraph types and iterators
|
| 88 |
98 |
|
| 89 |
99 |
///\see DIGRAPH_TYPEDEFS
|
| 90 |
100 |
///
|
| 91 |
101 |
///\note Use this macro, if the graph type is a dependent type,
|
| 92 |
102 |
///ie. the graph type depend on a template parameter.
|
| 93 |
103 |
#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph) \
|
| 94 |
104 |
typedef typename Digraph::Node Node; \
|
| 95 |
105 |
typedef typename Digraph::NodeIt NodeIt; \
|
| 96 |
106 |
typedef typename Digraph::Arc Arc; \
|
| 97 |
107 |
typedef typename Digraph::ArcIt ArcIt; \
|
| 98 |
108 |
typedef typename Digraph::InArcIt InArcIt; \
|
| 99 |
109 |
typedef typename Digraph::OutArcIt OutArcIt; \
|
| 100 |
110 |
typedef typename Digraph::template NodeMap<bool> BoolNodeMap; \
|
| 101 |
111 |
typedef typename Digraph::template NodeMap<int> IntNodeMap; \
|
| 102 |
112 |
typedef typename Digraph::template NodeMap<double> DoubleNodeMap; \
|
| 103 |
113 |
typedef typename Digraph::template ArcMap<bool> BoolArcMap; \
|
| 104 |
114 |
typedef typename Digraph::template ArcMap<int> IntArcMap; \
|
| 105 |
115 |
typedef typename Digraph::template ArcMap<double> DoubleArcMap
|
| 106 |
116 |
|
| 107 |
117 |
///Create convenience typedefs for the graph types and iterators
|
| 108 |
118 |
|
| 109 |
119 |
///This \c \#define creates the same convenient type definitions as defined
|
| 110 |
120 |
///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates
|
| 111 |
121 |
///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap,
|
| 112 |
122 |
///\c DoubleEdgeMap.
|
| 113 |
123 |
///
|
| 114 |
124 |
///\note If the graph type is a dependent type, ie. the graph type depend
|
| 115 |
125 |
///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS()
|
| 116 |
126 |
///macro.
|
| 117 |
127 |
#define GRAPH_TYPEDEFS(Graph) \
|
| 118 |
128 |
DIGRAPH_TYPEDEFS(Graph); \
|
| 119 |
129 |
typedef Graph::Edge Edge; \
|
| 120 |
130 |
typedef Graph::EdgeIt EdgeIt; \
|
| 121 |
131 |
typedef Graph::IncEdgeIt IncEdgeIt; \
|
| 122 |
132 |
typedef Graph::EdgeMap<bool> BoolEdgeMap; \
|
| 123 |
133 |
typedef Graph::EdgeMap<int> IntEdgeMap; \
|
| 124 |
134 |
typedef Graph::EdgeMap<double> DoubleEdgeMap
|
| 125 |
135 |
|
| 126 |
136 |
///Create convenience typedefs for the graph types and iterators
|
| 127 |
137 |
|
| 128 |
138 |
///\see GRAPH_TYPEDEFS
|
| 129 |
139 |
///
|
| 130 |
140 |
///\note Use this macro, if the graph type is a dependent type,
|
| 131 |
141 |
///ie. the graph type depend on a template parameter.
|
| 132 |
142 |
#define TEMPLATE_GRAPH_TYPEDEFS(Graph) \
|
| 133 |
143 |
TEMPLATE_DIGRAPH_TYPEDEFS(Graph); \
|
| 134 |
144 |
typedef typename Graph::Edge Edge; \
|
| 135 |
145 |
typedef typename Graph::EdgeIt EdgeIt; \
|
| 136 |
146 |
typedef typename Graph::IncEdgeIt IncEdgeIt; \
|
| 137 |
147 |
typedef typename Graph::template EdgeMap<bool> BoolEdgeMap; \
|
| 138 |
148 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap; \
|
| 139 |
149 |
typedef typename Graph::template EdgeMap<double> DoubleEdgeMap
|
| 140 |
150 |
|
| 141 |
151 |
/// \brief Function to count the items in a graph.
|
| 142 |
152 |
///
|
| 143 |
153 |
/// This function counts the items (nodes, arcs etc.) in a graph.
|
| 144 |
154 |
/// The complexity of the function is linear because
|
| 145 |
155 |
/// it iterates on all of the items.
|
| 146 |
156 |
template <typename Graph, typename Item>
|
| 147 |
157 |
inline int countItems(const Graph& g) {
|
| 148 |
158 |
typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
|
| 149 |
159 |
int num = 0;
|
| 150 |
160 |
for (ItemIt it(g); it != INVALID; ++it) {
|
| 151 |
161 |
++num;
|
| 152 |
162 |
}
|
| 153 |
163 |
return num;
|
| 154 |
164 |
}
|
| 155 |
165 |
|
| 156 |
166 |
// Node counting:
|
| 157 |
167 |
|
| 158 |
168 |
namespace _core_bits {
|
| 159 |
169 |
|
| 160 |
170 |
template <typename Graph, typename Enable = void>
|
| 161 |
171 |
struct CountNodesSelector {
|
| 162 |
172 |
static int count(const Graph &g) {
|
| 163 |
173 |
return countItems<Graph, typename Graph::Node>(g);
|
| 164 |
174 |
}
|
| 165 |
175 |
};
|
| 166 |
176 |
|
| 167 |
177 |
template <typename Graph>
|
| 168 |
178 |
struct CountNodesSelector<
|
| 169 |
179 |
Graph, typename
|
| 170 |
180 |
enable_if<typename Graph::NodeNumTag, void>::type>
|
| 171 |
181 |
{
|
| 172 |
182 |
static int count(const Graph &g) {
|
| 173 |
183 |
return g.nodeNum();
|
| 174 |
184 |
}
|
| 175 |
185 |
};
|
| 176 |
186 |
}
|
| 177 |
187 |
|
| 178 |
188 |
/// \brief Function to count the nodes in the graph.
|
| 179 |
189 |
///
|
| 180 |
190 |
/// This function counts the nodes in the graph.
|
| 181 |
191 |
/// The complexity of the function is <em>O</em>(<em>n</em>), but for some
|
| 182 |
192 |
/// graph structures it is specialized to run in <em>O</em>(1).
|
| 183 |
193 |
///
|
| 184 |
194 |
/// \note If the graph contains a \c nodeNum() member function and a
|
| 185 |
195 |
/// \c NodeNumTag tag then this function calls directly the member
|
| 186 |
196 |
/// function to query the cardinality of the node set.
|
| 187 |
197 |
template <typename Graph>
|
| 188 |
198 |
inline int countNodes(const Graph& g) {
|
| 189 |
199 |
return _core_bits::CountNodesSelector<Graph>::count(g);
|
| 190 |
200 |
}
|
| 191 |
201 |
|
| 192 |
202 |
// Arc counting:
|
| 193 |
203 |
|
| 194 |
204 |
namespace _core_bits {
|
| 195 |
205 |
|
| 196 |
206 |
template <typename Graph, typename Enable = void>
|
| 197 |
207 |
struct CountArcsSelector {
|
| 198 |
208 |
static int count(const Graph &g) {
|
| 199 |
209 |
return countItems<Graph, typename Graph::Arc>(g);
|
| 200 |
210 |
}
|
| 201 |
211 |
};
|
| 202 |
212 |
|
| 203 |
213 |
template <typename Graph>
|
| 204 |
214 |
struct CountArcsSelector<
|
| 205 |
215 |
Graph,
|
| 206 |
216 |
typename enable_if<typename Graph::ArcNumTag, void>::type>
|
| 207 |
217 |
{
|
| 208 |
218 |
static int count(const Graph &g) {
|
| 209 |
219 |
return g.arcNum();
|
| 210 |
220 |
}
|
| 211 |
221 |
};
|
| 212 |
222 |
}
|
| 213 |
223 |
|
| 214 |
224 |
/// \brief Function to count the arcs in the graph.
|
| 215 |
225 |
///
|
| 216 |
226 |
/// This function counts the arcs in the graph.
|
| 217 |
227 |
/// The complexity of the function is <em>O</em>(<em>m</em>), but for some
|
| 218 |
228 |
/// graph structures it is specialized to run in <em>O</em>(1).
|
| 219 |
229 |
///
|
| 220 |
230 |
/// \note If the graph contains a \c arcNum() member function and a
|
| 221 |
231 |
/// \c ArcNumTag tag then this function calls directly the member
|
| 222 |
232 |
/// function to query the cardinality of the arc set.
|
| 223 |
233 |
template <typename Graph>
|
| 224 |
234 |
inline int countArcs(const Graph& g) {
|
| 225 |
235 |
return _core_bits::CountArcsSelector<Graph>::count(g);
|
| 226 |
236 |
}
|
| 227 |
237 |
|
| 228 |
238 |
// Edge counting:
|
| 229 |
239 |
|
| 230 |
240 |
namespace _core_bits {
|
| 231 |
241 |
|
| 232 |
242 |
template <typename Graph, typename Enable = void>
|
| 233 |
243 |
struct CountEdgesSelector {
|
| 234 |
244 |
static int count(const Graph &g) {
|
| 235 |
245 |
return countItems<Graph, typename Graph::Edge>(g);
|
| 236 |
246 |
}
|
| 237 |
247 |
};
|
| 238 |
248 |
|
| 239 |
249 |
template <typename Graph>
|
| 240 |
250 |
struct CountEdgesSelector<
|
| 241 |
251 |
Graph,
|
| 242 |
252 |
typename enable_if<typename Graph::EdgeNumTag, void>::type>
|
| 243 |
253 |
{
|
| 244 |
254 |
static int count(const Graph &g) {
|
| 245 |
255 |
return g.edgeNum();
|
| 246 |
256 |
}
|
| 247 |
257 |
};
|
| 248 |
258 |
}
|
| 249 |
259 |
|
| 250 |
260 |
/// \brief Function to count the edges in the graph.
|
| 251 |
261 |
///
|
| 252 |
262 |
/// This function counts the edges in the graph.
|
| 253 |
263 |
/// The complexity of the function is <em>O</em>(<em>m</em>), but for some
|
| 254 |
264 |
/// graph structures it is specialized to run in <em>O</em>(1).
|
| 255 |
265 |
///
|
| 256 |
266 |
/// \note If the graph contains a \c edgeNum() member function and a
|
| 257 |
267 |
/// \c EdgeNumTag tag then this function calls directly the member
|
| 258 |
268 |
/// function to query the cardinality of the edge set.
|
| 259 |
269 |
template <typename Graph>
|
| 260 |
270 |
inline int countEdges(const Graph& g) {
|
| 261 |
271 |
return _core_bits::CountEdgesSelector<Graph>::count(g);
|
| 262 |
272 |
|
| 263 |
273 |
}
|
| 264 |
274 |
|
| 265 |
275 |
|
| 266 |
276 |
template <typename Graph, typename DegIt>
|
| 267 |
277 |
inline int countNodeDegree(const Graph& _g, const typename Graph::Node& _n) {
|
| 268 |
278 |
int num = 0;
|
| 269 |
279 |
for (DegIt it(_g, _n); it != INVALID; ++it) {
|
| 270 |
280 |
++num;
|
| 271 |
281 |
}
|
| 272 |
282 |
return num;
|
| 273 |
283 |
}
|
| 274 |
284 |
|
| 275 |
285 |
/// \brief Function to count the number of the out-arcs from node \c n.
|
| 276 |
286 |
///
|
| 277 |
287 |
/// This function counts the number of the out-arcs from node \c n
|
| 278 |
288 |
/// in the graph \c g.
|
| 279 |
289 |
template <typename Graph>
|
| 280 |
290 |
inline int countOutArcs(const Graph& g, const typename Graph::Node& n) {
|
| 281 |
291 |
return countNodeDegree<Graph, typename Graph::OutArcIt>(g, n);
|
| 282 |
292 |
}
|
| 283 |
293 |
|
| 284 |
294 |
/// \brief Function to count the number of the in-arcs to node \c n.
|
| 285 |
295 |
///
|
| 286 |
296 |
/// This function counts the number of the in-arcs to node \c n
|
| 287 |
297 |
/// in the graph \c g.
|
| 288 |
298 |
template <typename Graph>
|
| 289 |
299 |
inline int countInArcs(const Graph& g, const typename Graph::Node& n) {
|
| 290 |
300 |
return countNodeDegree<Graph, typename Graph::InArcIt>(g, n);
|
| 291 |
301 |
}
|
| 292 |
302 |
|
| 293 |
303 |
/// \brief Function to count the number of the inc-edges to node \c n.
|
| 294 |
304 |
///
|
| 295 |
305 |
/// This function counts the number of the inc-edges to node \c n
|
| 296 |
306 |
/// in the undirected graph \c g.
|
| 297 |
307 |
template <typename Graph>
|
| 298 |
308 |
inline int countIncEdges(const Graph& g, const typename Graph::Node& n) {
|
| 299 |
309 |
return countNodeDegree<Graph, typename Graph::IncEdgeIt>(g, n);
|
| 300 |
310 |
}
|
| 301 |
311 |
|
| 302 |
312 |
namespace _core_bits {
|
| 303 |
313 |
|
| 304 |
314 |
template <typename Digraph, typename Item, typename RefMap>
|
| 305 |
315 |
class MapCopyBase {
|
| 306 |
316 |
public:
|
| 307 |
317 |
virtual void copy(const Digraph& from, const RefMap& refMap) = 0;
|
| 308 |
318 |
|
| 309 |
319 |
virtual ~MapCopyBase() {}
|
| 310 |
320 |
};
|
| 311 |
321 |
|
| 312 |
322 |
template <typename Digraph, typename Item, typename RefMap,
|
| 313 |
323 |
typename FromMap, typename ToMap>
|
| 314 |
324 |
class MapCopy : public MapCopyBase<Digraph, Item, RefMap> {
|
| 315 |
325 |
public:
|
| 316 |
326 |
|
| 317 |
327 |
MapCopy(const FromMap& map, ToMap& tmap)
|
| 318 |
328 |
: _map(map), _tmap(tmap) {}
|
| 319 |
329 |
|
| 320 |
330 |
virtual void copy(const Digraph& digraph, const RefMap& refMap) {
|
| 321 |
331 |
typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
|
| 322 |
332 |
for (ItemIt it(digraph); it != INVALID; ++it) {
|
| 323 |
333 |
_tmap.set(refMap[it], _map[it]);
|
| 324 |
334 |
}
|
| 325 |
335 |
}
|
| 326 |
336 |
|
| 327 |
337 |
private:
|
| 328 |
338 |
const FromMap& _map;
|
| 329 |
339 |
ToMap& _tmap;
|
| 330 |
340 |
};
|
| 331 |
341 |
|
| 332 |
342 |
template <typename Digraph, typename Item, typename RefMap, typename It>
|
| 333 |
343 |
class ItemCopy : public MapCopyBase<Digraph, Item, RefMap> {
|
| 334 |
344 |
public:
|
| 335 |
345 |
|
| 336 |
346 |
ItemCopy(const Item& item, It& it) : _item(item), _it(it) {}
|
| 337 |
347 |
|
| 338 |
348 |
virtual void copy(const Digraph&, const RefMap& refMap) {
|
| 339 |
349 |
_it = refMap[_item];
|
| 340 |
350 |
}
|
| 341 |
351 |
|
| 342 |
352 |
private:
|
| 343 |
353 |
Item _item;
|
| 344 |
354 |
It& _it;
|
| 345 |
355 |
};
|
| 346 |
356 |
|
| 347 |
357 |
template <typename Digraph, typename Item, typename RefMap, typename Ref>
|
| 348 |
358 |
class RefCopy : public MapCopyBase<Digraph, Item, RefMap> {
|
| 349 |
359 |
public:
|
| 350 |
360 |
|
| 351 |
361 |
RefCopy(Ref& map) : _map(map) {}
|
| 352 |
362 |
|
| 353 |
363 |
virtual void copy(const Digraph& digraph, const RefMap& refMap) {
|
| 354 |
364 |
typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
|
| 355 |
365 |
for (ItemIt it(digraph); it != INVALID; ++it) {
|
| 356 |
366 |
_map.set(it, refMap[it]);
|
| 357 |
367 |
}
|
| 358 |
368 |
}
|
| 359 |
369 |
|
| 360 |
370 |
private:
|
| 361 |
371 |
Ref& _map;
|
| 362 |
372 |
};
|
| 363 |
373 |
|
| 364 |
374 |
template <typename Digraph, typename Item, typename RefMap,
|
| 365 |
375 |
typename CrossRef>
|
| 366 |
376 |
class CrossRefCopy : public MapCopyBase<Digraph, Item, RefMap> {
|
| 367 |
377 |
public:
|
| 368 |
378 |
|
| 369 |
379 |
CrossRefCopy(CrossRef& cmap) : _cmap(cmap) {}
|
| 370 |
380 |
|
| 371 |
381 |
virtual void copy(const Digraph& digraph, const RefMap& refMap) {
|
| 372 |
382 |
typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
|
| 373 |
383 |
for (ItemIt it(digraph); it != INVALID; ++it) {
|
| 374 |
384 |
_cmap.set(refMap[it], it);
|
| 375 |
385 |
}
|
| 376 |
386 |
}
|
| 377 |
387 |
|
| 378 |
388 |
private:
|
| 379 |
389 |
CrossRef& _cmap;
|
| 380 |
390 |
};
|
| 381 |
391 |
|
| 382 |
392 |
template <typename Digraph, typename Enable = void>
|
| 383 |
393 |
struct DigraphCopySelector {
|
| 384 |
394 |
template <typename From, typename NodeRefMap, typename ArcRefMap>
|
| 385 |
395 |
static void copy(const From& from, Digraph &to,
|
| 386 |
396 |
NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
|
| 387 |
397 |
for (typename From::NodeIt it(from); it != INVALID; ++it) {
|
| 388 |
398 |
nodeRefMap[it] = to.addNode();
|
| 389 |
399 |
}
|
| 390 |
400 |
for (typename From::ArcIt it(from); it != INVALID; ++it) {
|
| 391 |
401 |
arcRefMap[it] = to.addArc(nodeRefMap[from.source(it)],
|
| 392 |
402 |
nodeRefMap[from.target(it)]);
|
| 393 |
403 |
}
|
| 394 |
404 |
}
|
| 395 |
405 |
};
|
| 396 |
406 |
|
| 397 |
407 |
template <typename Digraph>
|
| 398 |
408 |
struct DigraphCopySelector<
|
| 399 |
409 |
Digraph,
|
| 400 |
410 |
typename enable_if<typename Digraph::BuildTag, void>::type>
|
| 401 |
411 |
{
|
| 402 |
412 |
template <typename From, typename NodeRefMap, typename ArcRefMap>
|
| 403 |
413 |
static void copy(const From& from, Digraph &to,
|
| 404 |
414 |
NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
|
| 405 |
415 |
to.build(from, nodeRefMap, arcRefMap);
|
| 406 |
416 |
}
|
| 407 |
417 |
};
|
| 408 |
418 |
|
| 409 |
419 |
template <typename Graph, typename Enable = void>
|
| 410 |
420 |
struct GraphCopySelector {
|
| 411 |
421 |
template <typename From, typename NodeRefMap, typename EdgeRefMap>
|
| 412 |
422 |
static void copy(const From& from, Graph &to,
|
| 413 |
423 |
NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
|
| 414 |
424 |
for (typename From::NodeIt it(from); it != INVALID; ++it) {
|
| 415 |
425 |
nodeRefMap[it] = to.addNode();
|
| 416 |
426 |
}
|
| 417 |
427 |
for (typename From::EdgeIt it(from); it != INVALID; ++it) {
|
| 418 |
428 |
edgeRefMap[it] = to.addEdge(nodeRefMap[from.u(it)],
|
| 419 |
429 |
nodeRefMap[from.v(it)]);
|
| 420 |
430 |
}
|
| 421 |
431 |
}
|
| 422 |
432 |
};
|
| 423 |
433 |
|
| 424 |
434 |
template <typename Graph>
|
| 425 |
435 |
struct GraphCopySelector<
|
| 426 |
436 |
Graph,
|
| 427 |
437 |
typename enable_if<typename Graph::BuildTag, void>::type>
|
| 428 |
438 |
{
|
| 429 |
439 |
template <typename From, typename NodeRefMap, typename EdgeRefMap>
|
| 430 |
440 |
static void copy(const From& from, Graph &to,
|
| 431 |
441 |
NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
|
| 432 |
442 |
to.build(from, nodeRefMap, edgeRefMap);
|
| 433 |
443 |
}
|
| 434 |
444 |
};
|
| 435 |
445 |
|
| 436 |
446 |
}
|
| 437 |
447 |
|
| 438 |
448 |
/// \brief Class to copy a digraph.
|
| 439 |
449 |
///
|
| 440 |
450 |
/// Class to copy a digraph to another digraph (duplicate a digraph). The
|
| 441 |
451 |
/// simplest way of using it is through the \c digraphCopy() function.
|
| 442 |
452 |
///
|
| 443 |
453 |
/// This class not only make a copy of a digraph, but it can create
|
| 444 |
454 |
/// references and cross references between the nodes and arcs of
|
| 445 |
455 |
/// the two digraphs, and it can copy maps to use with the newly created
|
| 446 |
456 |
/// digraph.
|
| 447 |
457 |
///
|
| 448 |
458 |
/// To make a copy from a digraph, first an instance of DigraphCopy
|
| 449 |
459 |
/// should be created, then the data belongs to the digraph should
|
| 450 |
460 |
/// assigned to copy. In the end, the \c run() member should be
|
| 451 |
461 |
/// called.
|
| 452 |
462 |
///
|
| 453 |
463 |
/// The next code copies a digraph with several data:
|
| 454 |
464 |
///\code
|
| 455 |
465 |
/// DigraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph);
|
| 456 |
466 |
/// // Create references for the nodes
|
| 457 |
467 |
/// OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
|
| 458 |
468 |
/// cg.nodeRef(nr);
|
| 459 |
469 |
/// // Create cross references (inverse) for the arcs
|
| 460 |
470 |
/// NewGraph::ArcMap<OrigGraph::Arc> acr(new_graph);
|
| 461 |
471 |
/// cg.arcCrossRef(acr);
|
| 462 |
472 |
/// // Copy an arc map
|
| 463 |
473 |
/// OrigGraph::ArcMap<double> oamap(orig_graph);
|
| 464 |
474 |
/// NewGraph::ArcMap<double> namap(new_graph);
|
| 465 |
475 |
/// cg.arcMap(oamap, namap);
|
| 466 |
476 |
/// // Copy a node
|
| 467 |
477 |
/// OrigGraph::Node on;
|
| 468 |
478 |
/// NewGraph::Node nn;
|
| 469 |
479 |
/// cg.node(on, nn);
|
| 470 |
480 |
/// // Execute copying
|
| 471 |
481 |
/// cg.run();
|
| 472 |
482 |
///\endcode
|
| 473 |
483 |
template <typename From, typename To>
|
| 474 |
484 |
class DigraphCopy {
|
| 475 |
485 |
private:
|
| 476 |
486 |
|
| 477 |
487 |
typedef typename From::Node Node;
|
| 478 |
488 |
typedef typename From::NodeIt NodeIt;
|
| 479 |
489 |
typedef typename From::Arc Arc;
|
| 480 |
490 |
typedef typename From::ArcIt ArcIt;
|
| 481 |
491 |
|
| 482 |
492 |
typedef typename To::Node TNode;
|
| 483 |
493 |
typedef typename To::Arc TArc;
|
| 484 |
494 |
|
| 485 |
495 |
typedef typename From::template NodeMap<TNode> NodeRefMap;
|
| 486 |
496 |
typedef typename From::template ArcMap<TArc> ArcRefMap;
|
| 487 |
497 |
|
| 488 |
498 |
public:
|
| 489 |
499 |
|
| 490 |
500 |
/// \brief Constructor of DigraphCopy.
|
| 491 |
501 |
///
|
| 492 |
502 |
/// Constructor of DigraphCopy for copying the content of the
|
| 493 |
503 |
/// \c from digraph into the \c to digraph.
|
| 494 |
504 |
DigraphCopy(const From& from, To& to)
|
| 495 |
505 |
: _from(from), _to(to) {}
|
| 496 |
506 |
|
| 497 |
507 |
/// \brief Destructor of DigraphCopy
|
| 498 |
508 |
///
|
| 499 |
509 |
/// Destructor of DigraphCopy.
|
| 500 |
510 |
~DigraphCopy() {
|
| 501 |
511 |
for (int i = 0; i < int(_node_maps.size()); ++i) {
|
| 502 |
512 |
delete _node_maps[i];
|
| 503 |
513 |
}
|
| 504 |
514 |
for (int i = 0; i < int(_arc_maps.size()); ++i) {
|
| 505 |
515 |
delete _arc_maps[i];
|
| 506 |
516 |
}
|
| 507 |
517 |
|
| 508 |
518 |
}
|
| 509 |
519 |
|
| 510 |
520 |
/// \brief Copy the node references into the given map.
|
| 511 |
521 |
///
|
| 512 |
522 |
/// This function copies the node references into the given map.
|
| 513 |
523 |
/// The parameter should be a map, whose key type is the Node type of
|
| 514 |
524 |
/// the source digraph, while the value type is the Node type of the
|
| 515 |
525 |
/// destination digraph.
|
| 516 |
526 |
template <typename NodeRef>
|
| 517 |
527 |
DigraphCopy& nodeRef(NodeRef& map) {
|
| 518 |
528 |
_node_maps.push_back(new _core_bits::RefCopy<From, Node,
|
| 519 |
529 |
NodeRefMap, NodeRef>(map));
|
| 520 |
530 |
return *this;
|
| 521 |
531 |
}
|
| 522 |
532 |
|
| 523 |
533 |
/// \brief Copy the node cross references into the given map.
|
| 524 |
534 |
///
|
| 525 |
535 |
/// This function copies the node cross references (reverse references)
|
| 526 |
536 |
/// into the given map. The parameter should be a map, whose key type
|
| 527 |
537 |
/// is the Node type of the destination digraph, while the value type is
|
| 528 |
538 |
/// the Node type of the source digraph.
|
| 529 |
539 |
template <typename NodeCrossRef>
|
| 530 |
540 |
DigraphCopy& nodeCrossRef(NodeCrossRef& map) {
|
| 531 |
541 |
_node_maps.push_back(new _core_bits::CrossRefCopy<From, Node,
|
| 532 |
542 |
NodeRefMap, NodeCrossRef>(map));
|
| 533 |
543 |
return *this;
|
| 534 |
544 |
}
|
| 535 |
545 |
|
| 536 |
546 |
/// \brief Make a copy of the given node map.
|
| 537 |
547 |
///
|
| 538 |
548 |
/// This function makes a copy of the given node map for the newly
|
| 539 |
549 |
/// created digraph.
|
| 540 |
550 |
/// The key type of the new map \c tmap should be the Node type of the
|
| 541 |
551 |
/// destination digraph, and the key type of the original map \c map
|
| 542 |
552 |
/// should be the Node type of the source digraph.
|
| 543 |
553 |
template <typename FromMap, typename ToMap>
|
| 544 |
554 |
DigraphCopy& nodeMap(const FromMap& map, ToMap& tmap) {
|
| 545 |
555 |
_node_maps.push_back(new _core_bits::MapCopy<From, Node,
|
| 546 |
556 |
NodeRefMap, FromMap, ToMap>(map, tmap));
|
| 547 |
557 |
return *this;
|
| 548 |
558 |
}
|
| 549 |
559 |
|
| 550 |
560 |
/// \brief Make a copy of the given node.
|
| 551 |
561 |
///
|
| 552 |
562 |
/// This function makes a copy of the given node.
|
| 553 |
563 |
DigraphCopy& node(const Node& node, TNode& tnode) {
|
| 554 |
564 |
_node_maps.push_back(new _core_bits::ItemCopy<From, Node,
|
| 555 |
565 |
NodeRefMap, TNode>(node, tnode));
|
| 556 |
566 |
return *this;
|
| 557 |
567 |
}
|
| 558 |
568 |
|
| 559 |
569 |
/// \brief Copy the arc references into the given map.
|
| 560 |
570 |
///
|
| 561 |
571 |
/// This function copies the arc references into the given map.
|
| 562 |
572 |
/// The parameter should be a map, whose key type is the Arc type of
|
| 563 |
573 |
/// the source digraph, while the value type is the Arc type of the
|
| 564 |
574 |
/// destination digraph.
|
| 565 |
575 |
template <typename ArcRef>
|
| 566 |
576 |
DigraphCopy& arcRef(ArcRef& map) {
|
| 567 |
577 |
_arc_maps.push_back(new _core_bits::RefCopy<From, Arc,
|
| 568 |
578 |
ArcRefMap, ArcRef>(map));
|
| 569 |
579 |
return *this;
|
| 570 |
580 |
}
|
| 571 |
581 |
|
| 572 |
582 |
/// \brief Copy the arc cross references into the given map.
|
| 573 |
583 |
///
|
| 574 |
584 |
/// This function copies the arc cross references (reverse references)
|
| 575 |
585 |
/// into the given map. The parameter should be a map, whose key type
|
| 576 |
586 |
/// is the Arc type of the destination digraph, while the value type is
|
| 577 |
587 |
/// the Arc type of the source digraph.
|
| 578 |
588 |
template <typename ArcCrossRef>
|
| 579 |
589 |
DigraphCopy& arcCrossRef(ArcCrossRef& map) {
|
| 580 |
590 |
_arc_maps.push_back(new _core_bits::CrossRefCopy<From, Arc,
|
| 581 |
591 |
ArcRefMap, ArcCrossRef>(map));
|
| 582 |
592 |
return *this;
|
| 583 |
593 |
}
|
| 584 |
594 |
|
| 585 |
595 |
/// \brief Make a copy of the given arc map.
|
| 586 |
596 |
///
|
| 587 |
597 |
/// This function makes a copy of the given arc map for the newly
|
| 588 |
598 |
/// created digraph.
|
| 589 |
599 |
/// The key type of the new map \c tmap should be the Arc type of the
|
| 590 |
600 |
/// destination digraph, and the key type of the original map \c map
|
| 591 |
601 |
/// should be the Arc type of the source digraph.
|
| 592 |
602 |
template <typename FromMap, typename ToMap>
|
| 593 |
603 |
DigraphCopy& arcMap(const FromMap& map, ToMap& tmap) {
|
| 594 |
604 |
_arc_maps.push_back(new _core_bits::MapCopy<From, Arc,
|
| 595 |
605 |
ArcRefMap, FromMap, ToMap>(map, tmap));
|
| 596 |
606 |
return *this;
|
| 597 |
607 |
}
|
| 598 |
608 |
|
| 599 |
609 |
/// \brief Make a copy of the given arc.
|
| 600 |
610 |
///
|
| 601 |
611 |
/// This function makes a copy of the given arc.
|
| 602 |
612 |
DigraphCopy& arc(const Arc& arc, TArc& tarc) {
|
| 603 |
613 |
_arc_maps.push_back(new _core_bits::ItemCopy<From, Arc,
|
| 604 |
614 |
ArcRefMap, TArc>(arc, tarc));
|
| 605 |
615 |
return *this;
|
| 606 |
616 |
}
|
| 607 |
617 |
|
| 608 |
618 |
/// \brief Execute copying.
|
| 609 |
619 |
///
|
| 610 |
620 |
/// This function executes the copying of the digraph along with the
|
| 611 |
621 |
/// copying of the assigned data.
|
| 612 |
622 |
void run() {
|
| 613 |
623 |
NodeRefMap nodeRefMap(_from);
|
| 614 |
624 |
ArcRefMap arcRefMap(_from);
|
| 615 |
625 |
_core_bits::DigraphCopySelector<To>::
|
| 616 |
626 |
copy(_from, _to, nodeRefMap, arcRefMap);
|
| 617 |
627 |
for (int i = 0; i < int(_node_maps.size()); ++i) {
|
| 618 |
628 |
_node_maps[i]->copy(_from, nodeRefMap);
|
| 619 |
629 |
}
|
| 620 |
630 |
for (int i = 0; i < int(_arc_maps.size()); ++i) {
|
| 621 |
631 |
_arc_maps[i]->copy(_from, arcRefMap);
|
| 622 |
632 |
}
|
| 623 |
633 |
}
|
| 624 |
634 |
|
| 625 |
635 |
protected:
|
| 626 |
636 |
|
| 627 |
637 |
const From& _from;
|
| 628 |
638 |
To& _to;
|
| 629 |
639 |
|
| 630 |
640 |
std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* >
|
| 631 |
641 |
_node_maps;
|
| 632 |
642 |
|
| 633 |
643 |
std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* >
|
| 634 |
644 |
_arc_maps;
|
| 635 |
645 |
|
| 636 |
646 |
};
|
| 637 |
647 |
|
| 638 |
648 |
/// \brief Copy a digraph to another digraph.
|
| 639 |
649 |
///
|
| 640 |
650 |
/// This function copies a digraph to another digraph.
|
| 641 |
651 |
/// The complete usage of it is detailed in the DigraphCopy class, but
|
| 642 |
652 |
/// a short example shows a basic work:
|
| 643 |
653 |
///\code
|
| 644 |
654 |
/// digraphCopy(src, trg).nodeRef(nr).arcCrossRef(acr).run();
|
| 645 |
655 |
///\endcode
|
| 646 |
656 |
///
|
| 647 |
657 |
/// After the copy the \c nr map will contain the mapping from the
|
| 648 |
658 |
/// nodes of the \c from digraph to the nodes of the \c to digraph and
|
| 649 |
659 |
/// \c acr will contain the mapping from the arcs of the \c to digraph
|
| 650 |
660 |
/// to the arcs of the \c from digraph.
|
| 651 |
661 |
///
|
| 652 |
662 |
/// \see DigraphCopy
|
| 653 |
663 |
template <typename From, typename To>
|
| 654 |
664 |
DigraphCopy<From, To> digraphCopy(const From& from, To& to) {
|
| 655 |
665 |
return DigraphCopy<From, To>(from, to);
|
| 656 |
666 |
}
|
| 657 |
667 |
|
| 658 |
668 |
/// \brief Class to copy a graph.
|
| 659 |
669 |
///
|
| 660 |
670 |
/// Class to copy a graph to another graph (duplicate a graph). The
|
| 661 |
671 |
/// simplest way of using it is through the \c graphCopy() function.
|
| 662 |
672 |
///
|
| 663 |
673 |
/// This class not only make a copy of a graph, but it can create
|
| 664 |
674 |
/// references and cross references between the nodes, edges and arcs of
|
| 665 |
675 |
/// the two graphs, and it can copy maps for using with the newly created
|
| 666 |
676 |
/// graph.
|
| 667 |
677 |
///
|
| 668 |
678 |
/// To make a copy from a graph, first an instance of GraphCopy
|
| 669 |
679 |
/// should be created, then the data belongs to the graph should
|
| 670 |
680 |
/// assigned to copy. In the end, the \c run() member should be
|
| 671 |
681 |
/// called.
|
| 672 |
682 |
///
|
| 673 |
683 |
/// The next code copies a graph with several data:
|
| 674 |
684 |
///\code
|
| 675 |
685 |
/// GraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph);
|
| 676 |
686 |
/// // Create references for the nodes
|
| 677 |
687 |
/// OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
|
| 678 |
688 |
/// cg.nodeRef(nr);
|
| 679 |
689 |
/// // Create cross references (inverse) for the edges
|
| 680 |
690 |
/// NewGraph::EdgeMap<OrigGraph::Edge> ecr(new_graph);
|
| 681 |
691 |
/// cg.edgeCrossRef(ecr);
|
| 682 |
692 |
/// // Copy an edge map
|
| 683 |
693 |
/// OrigGraph::EdgeMap<double> oemap(orig_graph);
|
| 684 |
694 |
/// NewGraph::EdgeMap<double> nemap(new_graph);
|
| 685 |
695 |
/// cg.edgeMap(oemap, nemap);
|
| 686 |
696 |
/// // Copy a node
|
| 687 |
697 |
/// OrigGraph::Node on;
|
| 688 |
698 |
/// NewGraph::Node nn;
|
| 689 |
699 |
/// cg.node(on, nn);
|
| 690 |
700 |
/// // Execute copying
|
| 691 |
701 |
/// cg.run();
|
| 692 |
702 |
///\endcode
|
| 693 |
703 |
template <typename From, typename To>
|
| 694 |
704 |
class GraphCopy {
|
| 695 |
705 |
private:
|
| 696 |
706 |
|
| 697 |
707 |
typedef typename From::Node Node;
|
| 698 |
708 |
typedef typename From::NodeIt NodeIt;
|
| 699 |
709 |
typedef typename From::Arc Arc;
|
| 700 |
710 |
typedef typename From::ArcIt ArcIt;
|
| 701 |
711 |
typedef typename From::Edge Edge;
|
| 702 |
712 |
typedef typename From::EdgeIt EdgeIt;
|
| 703 |
713 |
|
| 704 |
714 |
typedef typename To::Node TNode;
|
| 705 |
715 |
typedef typename To::Arc TArc;
|
| 706 |
716 |
typedef typename To::Edge TEdge;
|
| 707 |
717 |
|
| 708 |
718 |
typedef typename From::template NodeMap<TNode> NodeRefMap;
|
| 709 |
719 |
typedef typename From::template EdgeMap<TEdge> EdgeRefMap;
|
| 710 |
720 |
|
| 711 |
721 |
struct ArcRefMap {
|
| 712 |
722 |
ArcRefMap(const From& from, const To& to,
|
| 713 |
723 |
const EdgeRefMap& edge_ref, const NodeRefMap& node_ref)
|
| 714 |
724 |
: _from(from), _to(to),
|
| 715 |
725 |
_edge_ref(edge_ref), _node_ref(node_ref) {}
|
| 716 |
726 |
|
| 717 |
727 |
typedef typename From::Arc Key;
|
| 718 |
728 |
typedef typename To::Arc Value;
|
| 719 |
729 |
|
| 720 |
730 |
Value operator[](const Key& key) const {
|
| 721 |
731 |
bool forward = _from.u(key) != _from.v(key) ?
|
| 722 |
732 |
_node_ref[_from.source(key)] ==
|
| 723 |
733 |
_to.source(_to.direct(_edge_ref[key], true)) :
|
| 724 |
734 |
_from.direction(key);
|
| 725 |
735 |
return _to.direct(_edge_ref[key], forward);
|
| 726 |
736 |
}
|
| 727 |
737 |
|
| 728 |
738 |
const From& _from;
|
| 729 |
739 |
const To& _to;
|
| 730 |
740 |
const EdgeRefMap& _edge_ref;
|
| 731 |
741 |
const NodeRefMap& _node_ref;
|
| 732 |
742 |
};
|
| 733 |
743 |
|
| 734 |
744 |
public:
|
| 735 |
745 |
|
| 736 |
746 |
/// \brief Constructor of GraphCopy.
|
| 737 |
747 |
///
|
| 738 |
748 |
/// Constructor of GraphCopy for copying the content of the
|
| 739 |
749 |
/// \c from graph into the \c to graph.
|
| 740 |
750 |
GraphCopy(const From& from, To& to)
|
| 741 |
751 |
: _from(from), _to(to) {}
|
| 742 |
752 |
|
| 743 |
753 |
/// \brief Destructor of GraphCopy
|
| 744 |
754 |
///
|
| 745 |
755 |
/// Destructor of GraphCopy.
|
| 746 |
756 |
~GraphCopy() {
|
| 747 |
757 |
for (int i = 0; i < int(_node_maps.size()); ++i) {
|
| 748 |
758 |
delete _node_maps[i];
|
| 749 |
759 |
}
|
| 750 |
760 |
for (int i = 0; i < int(_arc_maps.size()); ++i) {
|
| 751 |
761 |
delete _arc_maps[i];
|
| 752 |
762 |
}
|
| 753 |
763 |
for (int i = 0; i < int(_edge_maps.size()); ++i) {
|
| 754 |
764 |
delete _edge_maps[i];
|
| 755 |
765 |
}
|
| 756 |
766 |
}
|
| 757 |
767 |
|
| 758 |
768 |
/// \brief Copy the node references into the given map.
|
| 759 |
769 |
///
|
| 760 |
770 |
/// This function copies the node references into the given map.
|
| 761 |
771 |
/// The parameter should be a map, whose key type is the Node type of
|
| 762 |
772 |
/// the source graph, while the value type is the Node type of the
|
| 763 |
773 |
/// destination graph.
|
| 764 |
774 |
template <typename NodeRef>
|
| 765 |
775 |
GraphCopy& nodeRef(NodeRef& map) {
|
| 766 |
776 |
_node_maps.push_back(new _core_bits::RefCopy<From, Node,
|
| 767 |
777 |
NodeRefMap, NodeRef>(map));
|
| 768 |
778 |
return *this;
|
| 769 |
779 |
}
|
| 770 |
780 |
|
| 771 |
781 |
/// \brief Copy the node cross references into the given map.
|
| 772 |
782 |
///
|
| 773 |
783 |
/// This function copies the node cross references (reverse references)
|
| 774 |
784 |
/// into the given map. The parameter should be a map, whose key type
|
| 775 |
785 |
/// is the Node type of the destination graph, while the value type is
|
| 776 |
786 |
/// the Node type of the source graph.
|
| 777 |
787 |
template <typename NodeCrossRef>
|
| 778 |
788 |
GraphCopy& nodeCrossRef(NodeCrossRef& map) {
|
| 779 |
789 |
_node_maps.push_back(new _core_bits::CrossRefCopy<From, Node,
|
| 780 |
790 |
NodeRefMap, NodeCrossRef>(map));
|
| 781 |
791 |
return *this;
|
| 782 |
792 |
}
|
| 783 |
793 |
|
| 784 |
794 |
/// \brief Make a copy of the given node map.
|
| 785 |
795 |
///
|
| 786 |
796 |
/// This function makes a copy of the given node map for the newly
|
| 787 |
797 |
/// created graph.
|
| 788 |
798 |
/// The key type of the new map \c tmap should be the Node type of the
|
| 789 |
799 |
/// destination graph, and the key type of the original map \c map
|
| 790 |
800 |
/// should be the Node type of the source graph.
|
| 791 |
801 |
template <typename FromMap, typename ToMap>
|
| 792 |
802 |
GraphCopy& nodeMap(const FromMap& map, ToMap& tmap) {
|
| 793 |
803 |
_node_maps.push_back(new _core_bits::MapCopy<From, Node,
|
| 794 |
804 |
NodeRefMap, FromMap, ToMap>(map, tmap));
|
| 795 |
805 |
return *this;
|
| 796 |
806 |
}
|
| 797 |
807 |
|