0
2
0
| ... | ... |
@@ -35,4 +35,4 @@ |
| 35 | 35 |
|
| 36 |
/// \brief Implementation of an algorithm for finding arc-disjoint |
|
| 37 |
/// paths between two nodes having minimum total length. |
|
| 36 |
/// \brief Algorithm for finding arc-disjoint paths between two nodes |
|
| 37 |
/// having minimum total length. |
|
| 38 | 38 |
/// |
| ... | ... |
@@ -40,4 +40,3 @@ |
| 40 | 40 |
/// finding arc-disjoint paths having minimum total length (cost) |
| 41 |
/// from a given source node to a given target node in a directed |
|
| 42 |
/// digraph. |
|
| 41 |
/// from a given source node to a given target node in a digraph. |
|
| 43 | 42 |
/// |
| ... | ... |
@@ -46,4 +45,6 @@ |
| 46 | 45 |
/// |
| 47 |
/// \tparam Digraph The |
|
| 46 |
/// \tparam Digraph The digraph type the algorithm runs on. |
|
| 47 |
/// The default value is \c ListDigraph. |
|
| 48 | 48 |
/// \tparam LengthMap The type of the length (cost) map. |
| 49 |
/// The default value is <tt>Digraph::ArcMap<int></tt>. |
|
| 49 | 50 |
/// |
| ... | ... |
@@ -53,7 +54,8 @@ |
| 53 | 54 |
/// with \ref SplitDigraphAdaptor. |
| 54 |
/// |
|
| 55 |
/// \author Attila Bernath and Peter Kovacs |
|
| 56 |
|
|
| 57 |
template < typename Digraph, |
|
| 55 |
#ifdef DOXYGEN |
|
| 56 |
template <typename Digraph, typename LengthMap> |
|
| 57 |
#else |
|
| 58 |
template < typename Digraph = ListDigraph, |
|
| 58 | 59 |
typename LengthMap = typename Digraph::template ArcMap<int> > |
| 60 |
#endif |
|
| 59 | 61 |
class Suurballe |
| ... | ... |
@@ -77,3 +79,3 @@ |
| 77 | 79 |
|
| 78 |
/// \brief Special implementation of the |
|
| 80 |
/// \brief Special implementation of the Dijkstra algorithm |
|
| 79 | 81 |
/// for finding shortest paths in the residual network. |
| ... | ... |
@@ -92,3 +94,3 @@ |
| 92 | 94 |
|
| 93 |
// The |
|
| 95 |
// The digraph the algorithm runs on |
|
| 94 | 96 |
const Digraph &_graph; |
| ... | ... |
@@ -122,3 +124,3 @@ |
| 122 | 124 |
|
| 123 |
/// \brief |
|
| 125 |
/// \brief Run the algorithm. It returns \c true if a path is found |
|
| 124 | 126 |
/// from the source node to the target node. |
| ... | ... |
@@ -131,3 +133,3 @@ |
| 131 | 133 |
|
| 132 |
// |
|
| 134 |
// Process nodes |
|
| 133 | 135 |
while (!heap.empty() && heap.top() != _t) {
|
| ... | ... |
@@ -139,3 +141,3 @@ |
| 139 | 141 |
|
| 140 |
// |
|
| 142 |
// Traverse outgoing arcs |
|
| 141 | 143 |
for (OutArcIt e(_graph, u); e != INVALID; ++e) {
|
| ... | ... |
@@ -161,3 +163,3 @@ |
| 161 | 163 |
|
| 162 |
// |
|
| 164 |
// Traverse incoming arcs |
|
| 163 | 165 |
for (InArcIt e(_graph, u); e != INVALID; ++e) {
|
| ... | ... |
@@ -185,3 +187,3 @@ |
| 185 | 187 |
|
| 186 |
// |
|
| 188 |
// Update potentials of processed nodes |
|
| 187 | 189 |
Length t_dist = heap.prio(); |
| ... | ... |
@@ -196,3 +198,3 @@ |
| 196 | 198 |
|
| 197 |
// The |
|
| 199 |
// The digraph the algorithm runs on |
|
| 198 | 200 |
const Digraph &_graph; |
| ... | ... |
@@ -229,3 +231,3 @@ |
| 229 | 231 |
/// |
| 230 |
/// \param digraph The |
|
| 232 |
/// \param digraph The digraph the algorithm runs on. |
|
| 231 | 233 |
/// \param length The length (cost) values of the arcs. |
| ... | ... |
@@ -247,5 +249,5 @@ |
| 247 | 249 |
|
| 248 |
/// \brief |
|
| 250 |
/// \brief Set the flow map. |
|
| 249 | 251 |
/// |
| 250 |
/// |
|
| 252 |
/// This function sets the flow map. |
|
| 251 | 253 |
/// |
| ... | ... |
@@ -264,5 +266,5 @@ |
| 264 | 266 |
|
| 265 |
/// \brief |
|
| 267 |
/// \brief Set the potential map. |
|
| 266 | 268 |
/// |
| 267 |
/// |
|
| 269 |
/// This function sets the potential map. |
|
| 268 | 270 |
/// |
| ... | ... |
@@ -290,5 +292,5 @@ |
| 290 | 292 |
|
| 291 |
/// \brief |
|
| 293 |
/// \brief Run the algorithm. |
|
| 292 | 294 |
/// |
| 293 |
/// |
|
| 295 |
/// This function runs the algorithm. |
|
| 294 | 296 |
/// |
| ... | ... |
@@ -296,4 +298,4 @@ |
| 296 | 298 |
/// |
| 297 |
/// \return \c k if there are at least \c k arc-disjoint paths |
|
| 298 |
/// from \c s to \c t. Otherwise it returns the number of |
|
| 299 |
/// \return \c k if there are at least \c k arc-disjoint paths from |
|
| 300 |
/// \c s to \c t in the digraph. Otherwise it returns the number of |
|
| 299 | 301 |
/// arc-disjoint paths found. |
| ... | ... |
@@ -314,7 +316,7 @@ |
| 314 | 316 |
|
| 315 |
/// \brief |
|
| 317 |
/// \brief Initialize the algorithm. |
|
| 316 | 318 |
/// |
| 317 |
/// |
|
| 319 |
/// This function initializes the algorithm. |
|
| 318 | 320 |
void init() {
|
| 319 |
// |
|
| 321 |
// Initialize maps |
|
| 320 | 322 |
if (!_flow) {
|
| ... | ... |
@@ -335,11 +337,11 @@ |
| 335 | 337 |
|
| 336 |
/// \brief |
|
| 338 |
/// \brief Execute the successive shortest path algorithm to find |
|
| 337 | 339 |
/// an optimal flow. |
| 338 | 340 |
/// |
| 339 |
/// Executes the successive shortest path algorithm to find a |
|
| 340 |
/// minimum cost flow, which is the union of \c k or less |
|
| 341 |
/// This function executes the successive shortest path algorithm to |
|
| 342 |
/// find a minimum cost flow, which is the union of \c k or less |
|
| 341 | 343 |
/// arc-disjoint paths. |
| 342 | 344 |
/// |
| 343 |
/// \return \c k if there are at least \c k arc-disjoint paths |
|
| 344 |
/// from \c s to \c t. Otherwise it returns the number of |
|
| 345 |
/// \return \c k if there are at least \c k arc-disjoint paths from |
|
| 346 |
/// \c s to \c t in the digraph. Otherwise it returns the number of |
|
| 345 | 347 |
/// arc-disjoint paths found. |
| ... | ... |
@@ -348,6 +350,6 @@ |
| 348 | 350 |
int findFlow(int k = 2) {
|
| 349 |
// |
|
| 351 |
// Find shortest paths |
|
| 350 | 352 |
_path_num = 0; |
| 351 | 353 |
while (_path_num < k) {
|
| 352 |
// |
|
| 354 |
// Run Dijkstra |
|
| 353 | 355 |
if (!_dijkstra->run()) break; |
| ... | ... |
@@ -355,3 +357,3 @@ |
| 355 | 357 |
|
| 356 |
// |
|
| 358 |
// Set the flow along the found shortest path |
|
| 357 | 359 |
Node u = _target; |
| ... | ... |
@@ -371,5 +373,5 @@ |
| 371 | 373 |
|
| 372 |
/// \brief |
|
| 374 |
/// \brief Compute the paths from the flow. |
|
| 373 | 375 |
/// |
| 374 |
/// |
|
| 376 |
/// This function computes the paths from the flow. |
|
| 375 | 377 |
/// |
| ... | ... |
@@ -378,4 +380,4 @@ |
| 378 | 380 |
void findPaths() {
|
| 379 |
// Creating the residual flow map (the union of the paths not |
|
| 380 |
// found so far) |
|
| 381 |
// Create the residual flow map (the union of the paths not found |
|
| 382 |
// so far) |
|
| 381 | 383 |
FlowMap res_flow(_graph); |
| ... | ... |
@@ -400,3 +402,3 @@ |
| 400 | 402 |
/// \name Query Functions |
| 401 |
/// The |
|
| 403 |
/// The results of the algorithm can be obtained using these |
|
| 402 | 404 |
/// functions. |
| ... | ... |
@@ -406,10 +408,10 @@ |
| 406 | 408 |
|
| 407 |
/// \brief |
|
| 409 |
/// \brief Return a const reference to the arc map storing the |
|
| 408 | 410 |
/// found flow. |
| 409 | 411 |
/// |
| 410 |
/// Returns a const reference to the arc map storing the flow that |
|
| 411 |
/// is the union of the found arc-disjoint paths. |
|
| 412 |
/// This function returns a const reference to the arc map storing |
|
| 413 |
/// the flow that is the union of the found arc-disjoint paths. |
|
| 412 | 414 |
/// |
| 413 |
/// \pre \ref run() or findFlow() must be called before using this |
|
| 414 |
/// function. |
|
| 415 |
/// \pre \ref run() or \ref findFlow() must be called before using |
|
| 416 |
/// this function. |
|
| 415 | 417 |
const FlowMap& flowMap() const {
|
| ... | ... |
@@ -418,11 +420,11 @@ |
| 418 | 420 |
|
| 419 |
/// \brief |
|
| 421 |
/// \brief Return a const reference to the node map storing the |
|
| 420 | 422 |
/// found potentials (the dual solution). |
| 421 | 423 |
/// |
| 422 |
/// Returns a const reference to the node map storing the found |
|
| 423 |
/// potentials that provide the dual solution of the underlying |
|
| 424 |
/// |
|
| 424 |
/// This function returns a const reference to the node map storing |
|
| 425 |
/// the found potentials that provide the dual solution of the |
|
| 426 |
/// underlying minimum cost flow problem. |
|
| 425 | 427 |
/// |
| 426 |
/// \pre \ref run() or findFlow() must be called before using this |
|
| 427 |
/// function. |
|
| 428 |
/// \pre \ref run() or \ref findFlow() must be called before using |
|
| 429 |
/// this function. |
|
| 428 | 430 |
const PotentialMap& potentialMap() const {
|
| ... | ... |
@@ -431,5 +433,5 @@ |
| 431 | 433 |
|
| 432 |
/// \brief |
|
| 434 |
/// \brief Return the flow on the given arc. |
|
| 433 | 435 |
/// |
| 434 |
/// |
|
| 436 |
/// This function returns the flow on the given arc. |
|
| 435 | 437 |
/// It is \c 1 if the arc is involved in one of the found paths, |
| ... | ... |
@@ -437,4 +439,4 @@ |
| 437 | 439 |
/// |
| 438 |
/// \pre \ref run() or findFlow() must be called before using this |
|
| 439 |
/// function. |
|
| 440 |
/// \pre \ref run() or \ref findFlow() must be called before using |
|
| 441 |
/// this function. |
|
| 440 | 442 |
int flow(const Arc& arc) const {
|
| ... | ... |
@@ -443,8 +445,8 @@ |
| 443 | 445 |
|
| 444 |
/// \brief |
|
| 446 |
/// \brief Return the potential of the given node. |
|
| 445 | 447 |
/// |
| 446 |
/// |
|
| 448 |
/// This function returns the potential of the given node. |
|
| 447 | 449 |
/// |
| 448 |
/// \pre \ref run() or findFlow() must be called before using this |
|
| 449 |
/// function. |
|
| 450 |
/// \pre \ref run() or \ref findFlow() must be called before using |
|
| 451 |
/// this function. |
|
| 450 | 452 |
Length potential(const Node& node) const {
|
| ... | ... |
@@ -453,9 +455,9 @@ |
| 453 | 455 |
|
| 454 |
/// \brief |
|
| 456 |
/// \brief Return the total length (cost) of the found paths (flow). |
|
| 455 | 457 |
/// |
| 456 |
/// Returns the total length (cost) of the found paths (flow). |
|
| 457 |
/// The complexity of the function is \f$ O(e) \f$. |
|
| 458 |
/// This function returns the total length (cost) of the found paths |
|
| 459 |
/// (flow). The complexity of the function is \f$ O(e) \f$. |
|
| 458 | 460 |
/// |
| 459 |
/// \pre \ref run() or findFlow() must be called before using this |
|
| 460 |
/// function. |
|
| 461 |
/// \pre \ref run() or \ref findFlow() must be called before using |
|
| 462 |
/// this function. |
|
| 461 | 463 |
Length totalLength() const {
|
| ... | ... |
@@ -467,8 +469,8 @@ |
| 467 | 469 |
|
| 468 |
/// \brief |
|
| 470 |
/// \brief Return the number of the found paths. |
|
| 469 | 471 |
/// |
| 470 |
/// |
|
| 472 |
/// This function returns the number of the found paths. |
|
| 471 | 473 |
/// |
| 472 |
/// \pre \ref run() or findFlow() must be called before using this |
|
| 473 |
/// function. |
|
| 474 |
/// \pre \ref run() or \ref findFlow() must be called before using |
|
| 475 |
/// this function. |
|
| 474 | 476 |
int pathNum() const {
|
| ... | ... |
@@ -477,5 +479,5 @@ |
| 477 | 479 |
|
| 478 |
/// \brief |
|
| 480 |
/// \brief Return a const reference to the specified path. |
|
| 479 | 481 |
/// |
| 480 |
/// |
|
| 482 |
/// This function returns a const reference to the specified path. |
|
| 481 | 483 |
/// |
| ... | ... |
@@ -484,4 +486,4 @@ |
| 484 | 486 |
/// |
| 485 |
/// \pre \ref run() or findPaths() must be called before using this |
|
| 486 |
/// function. |
|
| 487 |
/// \pre \ref run() or \ref findPaths() must be called before using |
|
| 488 |
/// this function. |
|
| 487 | 489 |
Path path(int i) const {
|
| ... | ... |
@@ -30,3 +30,3 @@ |
| 30 | 30 |
|
| 31 |
// |
|
| 31 |
// Check the feasibility of the flow |
|
| 32 | 32 |
template <typename Digraph, typename FlowMap> |
| ... | ... |
@@ -54,3 +54,3 @@ |
| 54 | 54 |
|
| 55 |
// |
|
| 55 |
// Check the optimalitiy of the flow |
|
| 56 | 56 |
template < typename Digraph, typename CostMap, |
| ... | ... |
@@ -60,3 +60,3 @@ |
| 60 | 60 |
{
|
| 61 |
// |
|
| 61 |
// Check the "Complementary Slackness" optimality condition |
|
| 62 | 62 |
TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); |
| ... | ... |
@@ -73,3 +73,3 @@ |
| 73 | 73 |
|
| 74 |
// |
|
| 74 |
// Check a path |
|
| 75 | 75 |
template < typename Digraph, typename Path > |
| ... | ... |
@@ -78,3 +78,3 @@ |
| 78 | 78 |
{
|
| 79 |
// |
|
| 79 |
// Check the "Complementary Slackness" optimality condition |
|
| 80 | 80 |
TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); |
| ... | ... |
@@ -93,3 +93,3 @@ |
| 93 | 93 |
|
| 94 |
// |
|
| 94 |
// Read the test digraph |
|
| 95 | 95 |
ListDigraph digraph; |
| ... | ... |
@@ -113,3 +113,3 @@ |
| 113 | 113 |
|
| 114 |
// |
|
| 114 |
// Find 2 paths |
|
| 115 | 115 |
{
|
| ... | ... |
@@ -128,3 +128,3 @@ |
| 128 | 128 |
|
| 129 |
// |
|
| 129 |
// Find 3 paths |
|
| 130 | 130 |
{
|
| ... | ... |
@@ -143,3 +143,3 @@ |
| 143 | 143 |
|
| 144 |
// |
|
| 144 |
// Find 5 paths (only 3 can be found) |
|
| 145 | 145 |
{
|
0 comments (0 inline)