0
6
0
... | ... |
@@ -280,48 +280,52 @@ |
280 | 280 |
/// \name Named Template Parameters |
281 | 281 |
/// @{ |
282 | 282 |
|
283 | 283 |
template <typename T> |
284 | 284 |
struct SetHeapTraits : public Traits { |
285 | 285 |
typedef T Heap; |
286 | 286 |
}; |
287 | 287 |
|
288 | 288 |
/// \brief \ref named-templ-param "Named parameter" for setting |
289 | 289 |
/// \c Heap type. |
290 | 290 |
/// |
291 | 291 |
/// \ref named-templ-param "Named parameter" for setting \c Heap |
292 | 292 |
/// type, which is used for internal Dijkstra computations. |
293 | 293 |
/// It must conform to the \ref lemon::concepts::Heap "Heap" concept, |
294 | 294 |
/// its priority type must be \c Cost and its cross reference type |
295 | 295 |
/// must be \ref RangeMap "RangeMap<int>". |
296 | 296 |
template <typename T> |
297 | 297 |
struct SetHeap |
298 | 298 |
: public CapacityScaling<GR, V, C, SetHeapTraits<T> > { |
299 | 299 |
typedef CapacityScaling<GR, V, C, SetHeapTraits<T> > Create; |
300 | 300 |
}; |
301 | 301 |
|
302 | 302 |
/// @} |
303 | 303 |
|
304 |
protected: |
|
305 |
|
|
306 |
CapacityScaling() {} |
|
307 |
|
|
304 | 308 |
public: |
305 | 309 |
|
306 | 310 |
/// \brief Constructor. |
307 | 311 |
/// |
308 | 312 |
/// The constructor of the class. |
309 | 313 |
/// |
310 | 314 |
/// \param graph The digraph the algorithm runs on. |
311 | 315 |
CapacityScaling(const GR& graph) : |
312 | 316 |
_graph(graph), _node_id(graph), _arc_idf(graph), _arc_idb(graph), |
313 | 317 |
INF(std::numeric_limits<Value>::has_infinity ? |
314 | 318 |
std::numeric_limits<Value>::infinity() : |
315 | 319 |
std::numeric_limits<Value>::max()) |
316 | 320 |
{ |
317 | 321 |
// Check the number types |
318 | 322 |
LEMON_ASSERT(std::numeric_limits<Value>::is_signed, |
319 | 323 |
"The flow type of CapacityScaling must be signed"); |
320 | 324 |
LEMON_ASSERT(std::numeric_limits<Cost>::is_signed, |
321 | 325 |
"The cost type of CapacityScaling must be signed"); |
322 | 326 |
|
323 | 327 |
// Reset data structures |
324 | 328 |
reset(); |
325 | 329 |
} |
326 | 330 |
|
327 | 331 |
/// \name Parameters |
... | ... |
@@ -304,48 +304,52 @@ |
304 | 304 |
public: |
305 | 305 |
|
306 | 306 |
/// \name Named Template Parameters |
307 | 307 |
/// @{ |
308 | 308 |
|
309 | 309 |
template <typename T> |
310 | 310 |
struct SetLargeCostTraits : public Traits { |
311 | 311 |
typedef T LargeCost; |
312 | 312 |
}; |
313 | 313 |
|
314 | 314 |
/// \brief \ref named-templ-param "Named parameter" for setting |
315 | 315 |
/// \c LargeCost type. |
316 | 316 |
/// |
317 | 317 |
/// \ref named-templ-param "Named parameter" for setting \c LargeCost |
318 | 318 |
/// type, which is used for internal computations in the algorithm. |
319 | 319 |
/// \c Cost must be convertible to \c LargeCost. |
320 | 320 |
template <typename T> |
321 | 321 |
struct SetLargeCost |
322 | 322 |
: public CostScaling<GR, V, C, SetLargeCostTraits<T> > { |
323 | 323 |
typedef CostScaling<GR, V, C, SetLargeCostTraits<T> > Create; |
324 | 324 |
}; |
325 | 325 |
|
326 | 326 |
/// @} |
327 | 327 |
|
328 |
protected: |
|
329 |
|
|
330 |
CostScaling() {} |
|
331 |
|
|
328 | 332 |
public: |
329 | 333 |
|
330 | 334 |
/// \brief Constructor. |
331 | 335 |
/// |
332 | 336 |
/// The constructor of the class. |
333 | 337 |
/// |
334 | 338 |
/// \param graph The digraph the algorithm runs on. |
335 | 339 |
CostScaling(const GR& graph) : |
336 | 340 |
_graph(graph), _node_id(graph), _arc_idf(graph), _arc_idb(graph), |
337 | 341 |
_cost_map(_cost_vec), _pi_map(_pi), |
338 | 342 |
INF(std::numeric_limits<Value>::has_infinity ? |
339 | 343 |
std::numeric_limits<Value>::infinity() : |
340 | 344 |
std::numeric_limits<Value>::max()) |
341 | 345 |
{ |
342 | 346 |
// Check the number types |
343 | 347 |
LEMON_ASSERT(std::numeric_limits<Value>::is_signed, |
344 | 348 |
"The flow type of CostScaling must be signed"); |
345 | 349 |
LEMON_ASSERT(std::numeric_limits<Cost>::is_signed, |
346 | 350 |
"The cost type of CostScaling must be signed"); |
347 | 351 |
|
348 | 352 |
// Reset data structures |
349 | 353 |
reset(); |
350 | 354 |
} |
351 | 355 |
... | ... |
@@ -220,48 +220,52 @@ |
220 | 220 |
: public HartmannOrlin<GR, LEN, SetLargeValueTraits<T> > { |
221 | 221 |
typedef HartmannOrlin<GR, LEN, SetLargeValueTraits<T> > Create; |
222 | 222 |
}; |
223 | 223 |
|
224 | 224 |
template <typename T> |
225 | 225 |
struct SetPathTraits : public Traits { |
226 | 226 |
typedef T Path; |
227 | 227 |
}; |
228 | 228 |
|
229 | 229 |
/// \brief \ref named-templ-param "Named parameter" for setting |
230 | 230 |
/// \c %Path type. |
231 | 231 |
/// |
232 | 232 |
/// \ref named-templ-param "Named parameter" for setting the \c %Path |
233 | 233 |
/// type of the found cycles. |
234 | 234 |
/// It must conform to the \ref lemon::concepts::Path "Path" concept |
235 | 235 |
/// and it must have an \c addFront() function. |
236 | 236 |
template <typename T> |
237 | 237 |
struct SetPath |
238 | 238 |
: public HartmannOrlin<GR, LEN, SetPathTraits<T> > { |
239 | 239 |
typedef HartmannOrlin<GR, LEN, SetPathTraits<T> > Create; |
240 | 240 |
}; |
241 | 241 |
|
242 | 242 |
/// @} |
243 | 243 |
|
244 |
protected: |
|
245 |
|
|
246 |
HartmannOrlin() {} |
|
247 |
|
|
244 | 248 |
public: |
245 | 249 |
|
246 | 250 |
/// \brief Constructor. |
247 | 251 |
/// |
248 | 252 |
/// The constructor of the class. |
249 | 253 |
/// |
250 | 254 |
/// \param digraph The digraph the algorithm runs on. |
251 | 255 |
/// \param length The lengths (costs) of the arcs. |
252 | 256 |
HartmannOrlin( const Digraph &digraph, |
253 | 257 |
const LengthMap &length ) : |
254 | 258 |
_gr(digraph), _length(length), _comp(digraph), _out_arcs(digraph), |
255 | 259 |
_best_found(false), _best_length(0), _best_size(1), |
256 | 260 |
_cycle_path(NULL), _local_path(false), _data(digraph), |
257 | 261 |
INF(std::numeric_limits<LargeValue>::has_infinity ? |
258 | 262 |
std::numeric_limits<LargeValue>::infinity() : |
259 | 263 |
std::numeric_limits<LargeValue>::max()) |
260 | 264 |
{} |
261 | 265 |
|
262 | 266 |
/// Destructor. |
263 | 267 |
~HartmannOrlin() { |
264 | 268 |
if (_local_path) delete _cycle_path; |
265 | 269 |
} |
266 | 270 |
|
267 | 271 |
/// \brief Set the path structure for storing the found cycle. |
... | ... |
@@ -210,48 +210,52 @@ |
210 | 210 |
: public Howard<GR, LEN, SetLargeValueTraits<T> > { |
211 | 211 |
typedef Howard<GR, LEN, SetLargeValueTraits<T> > Create; |
212 | 212 |
}; |
213 | 213 |
|
214 | 214 |
template <typename T> |
215 | 215 |
struct SetPathTraits : public Traits { |
216 | 216 |
typedef T Path; |
217 | 217 |
}; |
218 | 218 |
|
219 | 219 |
/// \brief \ref named-templ-param "Named parameter" for setting |
220 | 220 |
/// \c %Path type. |
221 | 221 |
/// |
222 | 222 |
/// \ref named-templ-param "Named parameter" for setting the \c %Path |
223 | 223 |
/// type of the found cycles. |
224 | 224 |
/// It must conform to the \ref lemon::concepts::Path "Path" concept |
225 | 225 |
/// and it must have an \c addBack() function. |
226 | 226 |
template <typename T> |
227 | 227 |
struct SetPath |
228 | 228 |
: public Howard<GR, LEN, SetPathTraits<T> > { |
229 | 229 |
typedef Howard<GR, LEN, SetPathTraits<T> > Create; |
230 | 230 |
}; |
231 | 231 |
|
232 | 232 |
/// @} |
233 | 233 |
|
234 |
protected: |
|
235 |
|
|
236 |
Howard() {} |
|
237 |
|
|
234 | 238 |
public: |
235 | 239 |
|
236 | 240 |
/// \brief Constructor. |
237 | 241 |
/// |
238 | 242 |
/// The constructor of the class. |
239 | 243 |
/// |
240 | 244 |
/// \param digraph The digraph the algorithm runs on. |
241 | 245 |
/// \param length The lengths (costs) of the arcs. |
242 | 246 |
Howard( const Digraph &digraph, |
243 | 247 |
const LengthMap &length ) : |
244 | 248 |
_gr(digraph), _length(length), _best_found(false), |
245 | 249 |
_best_length(0), _best_size(1), _cycle_path(NULL), _local_path(false), |
246 | 250 |
_policy(digraph), _reached(digraph), _level(digraph), _dist(digraph), |
247 | 251 |
_comp(digraph), _in_arcs(digraph), |
248 | 252 |
INF(std::numeric_limits<LargeValue>::has_infinity ? |
249 | 253 |
std::numeric_limits<LargeValue>::infinity() : |
250 | 254 |
std::numeric_limits<LargeValue>::max()) |
251 | 255 |
{} |
252 | 256 |
|
253 | 257 |
/// Destructor. |
254 | 258 |
~Howard() { |
255 | 259 |
if (_local_path) delete _cycle_path; |
256 | 260 |
} |
257 | 261 |
... | ... |
@@ -216,48 +216,52 @@ |
216 | 216 |
: public Karp<GR, LEN, SetLargeValueTraits<T> > { |
217 | 217 |
typedef Karp<GR, LEN, SetLargeValueTraits<T> > Create; |
218 | 218 |
}; |
219 | 219 |
|
220 | 220 |
template <typename T> |
221 | 221 |
struct SetPathTraits : public Traits { |
222 | 222 |
typedef T Path; |
223 | 223 |
}; |
224 | 224 |
|
225 | 225 |
/// \brief \ref named-templ-param "Named parameter" for setting |
226 | 226 |
/// \c %Path type. |
227 | 227 |
/// |
228 | 228 |
/// \ref named-templ-param "Named parameter" for setting the \c %Path |
229 | 229 |
/// type of the found cycles. |
230 | 230 |
/// It must conform to the \ref lemon::concepts::Path "Path" concept |
231 | 231 |
/// and it must have an \c addFront() function. |
232 | 232 |
template <typename T> |
233 | 233 |
struct SetPath |
234 | 234 |
: public Karp<GR, LEN, SetPathTraits<T> > { |
235 | 235 |
typedef Karp<GR, LEN, SetPathTraits<T> > Create; |
236 | 236 |
}; |
237 | 237 |
|
238 | 238 |
/// @} |
239 | 239 |
|
240 |
protected: |
|
241 |
|
|
242 |
Karp() {} |
|
243 |
|
|
240 | 244 |
public: |
241 | 245 |
|
242 | 246 |
/// \brief Constructor. |
243 | 247 |
/// |
244 | 248 |
/// The constructor of the class. |
245 | 249 |
/// |
246 | 250 |
/// \param digraph The digraph the algorithm runs on. |
247 | 251 |
/// \param length The lengths (costs) of the arcs. |
248 | 252 |
Karp( const Digraph &digraph, |
249 | 253 |
const LengthMap &length ) : |
250 | 254 |
_gr(digraph), _length(length), _comp(digraph), _out_arcs(digraph), |
251 | 255 |
_cycle_length(0), _cycle_size(1), _cycle_node(INVALID), |
252 | 256 |
_cycle_path(NULL), _local_path(false), _data(digraph), |
253 | 257 |
INF(std::numeric_limits<LargeValue>::has_infinity ? |
254 | 258 |
std::numeric_limits<LargeValue>::infinity() : |
255 | 259 |
std::numeric_limits<LargeValue>::max()) |
256 | 260 |
{} |
257 | 261 |
|
258 | 262 |
/// Destructor. |
259 | 263 |
~Karp() { |
260 | 264 |
if (_local_path) delete _cycle_path; |
261 | 265 |
} |
262 | 266 |
|
263 | 267 |
/// \brief Set the path structure for storing the found cycle. |
... | ... |
@@ -382,48 +382,52 @@ |
382 | 382 |
// Arc map of the current flow |
383 | 383 |
FlowMap *_flow; |
384 | 384 |
bool _local_flow; |
385 | 385 |
// Node map of the current potentials |
386 | 386 |
PotentialMap *_potential; |
387 | 387 |
bool _local_potential; |
388 | 388 |
|
389 | 389 |
// The source node |
390 | 390 |
Node _s; |
391 | 391 |
// The target node |
392 | 392 |
Node _t; |
393 | 393 |
|
394 | 394 |
// Container to store the found paths |
395 | 395 |
std::vector<Path> _paths; |
396 | 396 |
int _path_num; |
397 | 397 |
|
398 | 398 |
// The pred arc map |
399 | 399 |
PredMap _pred; |
400 | 400 |
|
401 | 401 |
// Data for full init |
402 | 402 |
PotentialMap *_init_dist; |
403 | 403 |
PredMap *_init_pred; |
404 | 404 |
bool _full_init; |
405 | 405 |
|
406 |
protected: |
|
407 |
|
|
408 |
Suurballe() {} |
|
409 |
|
|
406 | 410 |
public: |
407 | 411 |
|
408 | 412 |
/// \brief Constructor. |
409 | 413 |
/// |
410 | 414 |
/// Constructor. |
411 | 415 |
/// |
412 | 416 |
/// \param graph The digraph the algorithm runs on. |
413 | 417 |
/// \param length The length (cost) values of the arcs. |
414 | 418 |
Suurballe( const Digraph &graph, |
415 | 419 |
const LengthMap &length ) : |
416 | 420 |
_graph(graph), _length(length), _flow(0), _local_flow(false), |
417 | 421 |
_potential(0), _local_potential(false), _pred(graph), |
418 | 422 |
_init_dist(0), _init_pred(0) |
419 | 423 |
{} |
420 | 424 |
|
421 | 425 |
/// Destructor. |
422 | 426 |
~Suurballe() { |
423 | 427 |
if (_local_flow) delete _flow; |
424 | 428 |
if (_local_potential) delete _potential; |
425 | 429 |
delete _init_dist; |
426 | 430 |
delete _init_pred; |
427 | 431 |
} |
428 | 432 |
|
429 | 433 |
/// \brief Set the flow map. |
0 comments (0 inline)