Changeset 2588:4d3bc1d04c1d in lemon-0.x
- Timestamp:
- 02/29/08 16:57:52 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3470
- Location:
- lemon
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/capacity_scaling.h
r2581 r2588 26 26 27 27 #include <vector> 28 29 #include <lemon/graph_adaptor.h>30 28 #include <lemon/bin_heap.h> 31 29 … … 91 89 class ResidualDijkstra 92 90 { 93 typedef typename Graph::template NodeMap<Cost> CostNodeMap;94 typedef typename Graph::template NodeMap<Edge> PredMap;95 96 91 typedef typename Graph::template NodeMap<int> HeapCrossRef; 97 92 typedef BinHeap<Cost, HeapCrossRef> Heap; … … 110 105 111 106 // The distance map 112 CostNodeMap _dist;107 PotentialMap _dist; 113 108 // The pred edge map 114 109 PredMap &_pred; … … 132 127 133 128 /// Runs the algorithm from the given source node. 134 Node run(Node s, Capacity delta ) {129 Node run(Node s, Capacity delta = 1) { 135 130 HeapCrossRef heap_cross_ref(_graph, Heap::PRE_HEAP); 136 131 Heap heap(heap_cross_ref); … … 455 450 } 456 451 457 /// \brief Returns the flow on the edge.458 /// 459 /// Returns the flow on the edge.452 /// \brief Returns the flow on the given edge. 453 /// 454 /// Returns the flow on the given edge. 460 455 /// 461 456 /// \pre \ref run() must be called before using this function. … … 464 459 } 465 460 466 /// \brief Returns the potential of the node.467 /// 468 /// Returns the potential of the node.461 /// \brief Returns the potential of the given node. 462 /// 463 /// Returns the potential of the given node. 469 464 /// 470 465 /// \pre \ref run() must be called before using this function. … … 518 513 if (-_supply[n] > max_dem) max_dem = -_supply[n]; 519 514 } 520 if (max_dem < max_sup) max_sup = max_dem; 515 Capacity max_cap = 0; 516 for (EdgeIt e(_graph); e != INVALID; ++e) { 517 if (_capacity[e] > max_cap) max_cap = _capacity[e]; 518 } 519 max_sup = std::min(std::min(max_sup, max_dem), max_cap); 521 520 _phase_num = 0; 522 521 for (_delta = 1; 2 * _delta <= max_sup; _delta *= 2) … … 596 595 597 596 // Augmenting along a shortest path from s to t. 598 Capacity d = _excess[s] < -_excess[t] ? _excess[s] : -_excess[t];597 Capacity d = std::min(_excess[s], -_excess[t]); 599 598 Node u = t; 600 599 Edge e; … … 658 657 // Running Dijkstra 659 658 s = _excess_nodes[next_node]; 660 if ((t = _dijkstra->run(s, 1)) == INVALID) 661 return false; 659 if ((t = _dijkstra->run(s)) == INVALID) break; 662 660 663 661 // Augmenting along a shortest path from s to t 664 Capacity d = _excess[s] < -_excess[t] ? _excess[s] : -_excess[t];662 Capacity d = std::min(_excess[s], -_excess[t]); 665 663 Node u = t; 666 664 Edge e; 667 while ((e = _pred[u]) != INVALID) { 668 Capacity rc; 669 if (u == _graph.target(e)) { 670 rc = _res_cap[e]; 671 u = _graph.source(e); 672 } else { 673 rc = (*_flow)[e]; 674 u = _graph.target(e); 675 } 676 if (rc < d) d = rc; 665 if (d > 1) { 666 while ((e = _pred[u]) != INVALID) { 667 Capacity rc; 668 if (u == _graph.target(e)) { 669 rc = _res_cap[e]; 670 u = _graph.source(e); 671 } else { 672 rc = (*_flow)[e]; 673 u = _graph.target(e); 674 } 675 if (rc < d) d = rc; 676 } 677 677 } 678 678 u = t; -
lemon/cost_scaling.h
r2581 r2588 400 400 } 401 401 402 /// \brief Returns the flow on the edge.403 /// 404 /// Returns the flow on the edge.402 /// \brief Returns the flow on the given edge. 403 /// 404 /// Returns the flow on the given edge. 405 405 /// 406 406 /// \pre \ref run() must be called before using this function. … … 409 409 } 410 410 411 /// \brief Returns the potential of the node.412 /// 413 /// Returns the potential of the node.411 /// \brief Returns the potential of the given node. 412 /// 413 /// Returns the potential of the given node. 414 414 /// 415 415 /// \pre \ref run() must be called before using this function. -
lemon/cycle_canceling.h
r2581 r2588 356 356 } 357 357 358 /// \brief Returns the flow on the edge.359 /// 360 /// Returns the flow on the edge.358 /// \brief Returns the flow on the given edge. 359 /// 360 /// Returns the flow on the given edge. 361 361 /// 362 362 /// \pre \ref run() must be called before using this function. … … 365 365 } 366 366 367 /// \brief Returns the potential of the node.368 /// 369 /// Returns the potential of the node.367 /// \brief Returns the potential of the given node. 368 /// 369 /// Returns the potential of the given node. 370 370 /// 371 371 /// \pre \ref run() must be called before using this function. -
lemon/min_cost_flow.h
r2581 r2588 45 45 /// There are four implementations for the minimum cost flow problem, 46 46 /// which can be used exactly the same way. 47 /// - \ref CapacityScaling The capacity scaling algorithm.48 /// - \ref CostScaling The cost scaling algorithm.49 /// - \ref CycleCanceling A cycle-canceling algorithm.50 /// - \ref NetworkSimplex The network simplex algorithm.47 /// - \ref CapacityScaling 48 /// - \ref CostScaling 49 /// - \ref CycleCanceling 50 /// - \ref NetworkSimplex 51 51 /// 52 52 /// \tparam Graph The directed graph type the algorithm runs on. -
lemon/min_mean_cycle.h
r2583 r2588 135 135 136 136 /// \name Execution control 137 /// The simplest way to execute the algorithm is to call run(). 137 /// The simplest way to execute the algorithm is to call the run() 138 /// function. 138 139 /// \n 139 140 /// If you only need the minimum mean value, you may call init() … … 238 239 /// The result of the algorithm can be obtained using these 239 240 /// functions. 240 /// \n run() must be called before using them.241 /// \n The algorithm should be executed before using them. 241 242 242 243 /// @{ -
lemon/network_simplex.h
r2581 r2588 777 777 } 778 778 779 /// \brief Returns the flow on the edge.780 /// 781 /// Returns the flow on the edge.779 /// \brief Returns the flow on the given edge. 780 /// 781 /// Returns the flow on the given edge. 782 782 /// 783 783 /// \pre \ref run() must be called before using this function. … … 786 786 } 787 787 788 /// \brief Returns the potential of the node.789 /// 790 /// Returns the potential of the node.788 /// \brief Returns the potential of the given node. 789 /// 790 /// Returns the potential of the given node. 791 791 /// 792 792 /// \pre \ref run() must be called before using this function.
Note: See TracChangeset
for help on using the changeset viewer.