| ... | ... |
@@ -68,96 +68,99 @@ |
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 | 70 |
/// \brief The elevator type used by Preflow algorithm. |
| 71 | 71 |
/// |
| 72 | 72 |
/// The elevator type used by Preflow algorithm. |
| 73 | 73 |
/// |
| 74 | 74 |
/// \sa Elevator, LinkedElevator |
| 75 | 75 |
#ifdef DOXYGEN |
| 76 | 76 |
typedef lemon::Elevator<GR, GR::Node> Elevator; |
| 77 | 77 |
#else |
| 78 | 78 |
typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator; |
| 79 | 79 |
#endif |
| 80 | 80 |
|
| 81 | 81 |
/// \brief Instantiates an Elevator. |
| 82 | 82 |
/// |
| 83 | 83 |
/// This function instantiates an \ref Elevator. |
| 84 | 84 |
/// \param digraph The digraph for which we would like to define |
| 85 | 85 |
/// the elevator. |
| 86 | 86 |
/// \param max_level The maximum level of the elevator. |
| 87 | 87 |
static Elevator* createElevator(const Digraph& digraph, int max_level) {
|
| 88 | 88 |
return new Elevator(digraph, max_level); |
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 | 91 |
/// \brief The tolerance used by the algorithm |
| 92 | 92 |
/// |
| 93 | 93 |
/// The tolerance used by the algorithm to handle inexact computation. |
| 94 | 94 |
typedef lemon::Tolerance<Value> Tolerance; |
| 95 | 95 |
|
| 96 | 96 |
}; |
| 97 | 97 |
|
| 98 | 98 |
|
| 99 | 99 |
/// \ingroup max_flow |
| 100 | 100 |
/// |
| 101 | 101 |
/// \brief %Preflow algorithm class. |
| 102 | 102 |
/// |
| 103 | 103 |
/// This class provides an implementation of Goldberg-Tarjan's \e preflow |
| 104 | 104 |
/// \e push-relabel algorithm producing a \ref max_flow |
| 105 | 105 |
/// "flow of maximum value" in a digraph \ref clrs01algorithms, |
| 106 | 106 |
/// \ref amo93networkflows, \ref goldberg88newapproach. |
| 107 | 107 |
/// The preflow algorithms are the fastest known maximum |
| 108 | 108 |
/// flow algorithms. The current implementation uses a mixture of the |
| 109 | 109 |
/// \e "highest label" and the \e "bound decrease" heuristics. |
| 110 | 110 |
/// The worst case time complexity of the algorithm is \f$O(n^2\sqrt{e})\f$.
|
| 111 | 111 |
/// |
| 112 | 112 |
/// The algorithm consists of two phases. After the first phase |
| 113 | 113 |
/// the maximum flow value and the minimum cut is obtained. The |
| 114 | 114 |
/// second phase constructs a feasible maximum flow on each arc. |
| 115 | 115 |
/// |
| 116 |
/// \warning This implementation cannot handle infinite or very large |
|
| 117 |
/// capacities (e.g. the maximum value of \c CAP::Value). |
|
| 118 |
/// |
|
| 116 | 119 |
/// \tparam GR The type of the digraph the algorithm runs on. |
| 117 | 120 |
/// \tparam CAP The type of the capacity map. The default map |
| 118 | 121 |
/// type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". |
| 119 | 122 |
#ifdef DOXYGEN |
| 120 | 123 |
template <typename GR, typename CAP, typename TR> |
| 121 | 124 |
#else |
| 122 | 125 |
template <typename GR, |
| 123 | 126 |
typename CAP = typename GR::template ArcMap<int>, |
| 124 | 127 |
typename TR = PreflowDefaultTraits<GR, CAP> > |
| 125 | 128 |
#endif |
| 126 | 129 |
class Preflow {
|
| 127 | 130 |
public: |
| 128 | 131 |
|
| 129 | 132 |
///The \ref PreflowDefaultTraits "traits class" of the algorithm. |
| 130 | 133 |
typedef TR Traits; |
| 131 | 134 |
///The type of the digraph the algorithm runs on. |
| 132 | 135 |
typedef typename Traits::Digraph Digraph; |
| 133 | 136 |
///The type of the capacity map. |
| 134 | 137 |
typedef typename Traits::CapacityMap CapacityMap; |
| 135 | 138 |
///The type of the flow values. |
| 136 | 139 |
typedef typename Traits::Value Value; |
| 137 | 140 |
|
| 138 | 141 |
///The type of the flow map. |
| 139 | 142 |
typedef typename Traits::FlowMap FlowMap; |
| 140 | 143 |
///The type of the elevator. |
| 141 | 144 |
typedef typename Traits::Elevator Elevator; |
| 142 | 145 |
///The type of the tolerance. |
| 143 | 146 |
typedef typename Traits::Tolerance Tolerance; |
| 144 | 147 |
|
| 145 | 148 |
private: |
| 146 | 149 |
|
| 147 | 150 |
TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); |
| 148 | 151 |
|
| 149 | 152 |
const Digraph& _graph; |
| 150 | 153 |
const CapacityMap* _capacity; |
| 151 | 154 |
|
| 152 | 155 |
int _node_num; |
| 153 | 156 |
|
| 154 | 157 |
Node _source, _target; |
| 155 | 158 |
|
| 156 | 159 |
FlowMap* _flow; |
| 157 | 160 |
bool _local_flow; |
| 158 | 161 |
|
| 159 | 162 |
Elevator* _level; |
| 160 | 163 |
bool _local_level; |
| 161 | 164 |
|
| 162 | 165 |
typedef typename Digraph::template NodeMap<Value> ExcessMap; |
| 163 | 166 |
ExcessMap* _excess; |
0 comments (0 inline)