File indexing completed on 2025-08-03 08:19:36
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef GTL_MAXFLOW_PP_H
0010 #define GTL_MAXFLOW_PP_H
0011
0012 #include <GTL/GTL.h>
0013 #include <GTL/graph.h>
0014 #include <GTL/node_map.h>
0015 #include <GTL/edge_map.h>
0016 #include <GTL/algorithm.h>
0017
0018 #include <queue>
0019
0020 __GTL_BEGIN_NAMESPACE
0021
0022
0023
0024
0025 class GTL_EXTERN maxflow_pp : public algorithm
0026 {
0027 public:
0028
0029
0030
0031
0032
0033
0034 maxflow_pp();
0035
0036
0037
0038
0039
0040
0041 virtual ~maxflow_pp();
0042
0043
0044
0045
0046
0047
0048
0049
0050 void set_vars(const edge_map<double>& edge_capacity);
0051
0052
0053
0054
0055
0056
0057
0058
0059 void set_vars(
0060 const edge_map<double>& edge_capacity,
0061 const node& net_source, const node& net_target);
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 virtual int check(graph& G);
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 int run(graph& G);
0092
0093
0094
0095
0096
0097
0098
0099 double get_max_flow(const edge& e) const;
0100
0101
0102
0103
0104
0105
0106 double get_max_flow() const;
0107
0108
0109
0110
0111
0112
0113
0114 double get_rem_cap(const edge& e) const;
0115
0116
0117
0118
0119
0120
0121 virtual void reset();
0122 protected:
0123
0124
0125
0126 enum {TARGET_FROM_SOURCE_REACHABLE = 2, TARGET_FROM_SOURCE_NOT_REACHABLE = 3};
0127
0128
0129
0130
0131 bool artif_source_target;
0132
0133
0134
0135
0136 bool set_vars_executed;
0137
0138
0139
0140
0141 double max_graph_flow;
0142
0143
0144
0145
0146 node net_source;
0147
0148
0149
0150
0151 node net_target;
0152
0153
0154
0155
0156 list<edge> edges_not_org;
0157
0158
0159
0160
0161 edge_map<bool> edge_org;
0162
0163
0164
0165
0166 edge_map<bool> back_edge_exists;
0167
0168
0169
0170
0171 edge_map<edge> back_edge;
0172
0173
0174
0175
0176 edge_map<double> edge_capacity;
0177
0178
0179
0180
0181 edge_map<double> edge_max_flow;
0182
0183
0184
0185
0186 edge_map<double> flow_update;
0187
0188
0189
0190
0191 list<edge> full_edges;
0192
0193
0194
0195
0196 list<node> temp_unvisible_nodes;
0197
0198
0199
0200
0201 list<edge> temp_unvisible_edges;
0202
0203
0204
0205
0206 void create_artif_source_target(graph& G);
0207
0208
0209
0210
0211 void prepare_run(const graph& G);
0212
0213
0214
0215
0216 int leveling(graph& G);
0217
0218
0219
0220
0221 void hide_unreachable_nodes(graph& G);
0222
0223
0224
0225
0226 void store_temp_unvisible_edges(const node& cur_node);
0227
0228
0229
0230
0231 void min_throughput_node(const graph& G, node& min_tp_node, double& min_value);
0232
0233
0234
0235
0236 double comp_min_throughput(const node cur_node) const;
0237
0238
0239
0240
0241 void get_sp_ahead(const graph& G, const node& start_node,
0242 node_map<edge>& last_edge);
0243
0244
0245
0246
0247 void get_sp_backwards(const graph& G, const node& start_node,
0248 node_map<edge>& prev_edge);
0249
0250
0251
0252
0253 void push(graph& G, const node& start_node, const double flow_value);
0254
0255
0256
0257
0258 void pull(graph& G, const node& start_node, const double flow_value);
0259
0260
0261
0262
0263 void comp_rem_net(graph& G);
0264
0265
0266
0267
0268 void single_edge_update(graph& G, edge cur_edge);
0269
0270
0271
0272
0273 double extra_charge_ahead(const node& start_node, const
0274 node_map<edge>& last_edge) const;
0275
0276
0277
0278
0279 double extra_charge_backwards(const node& start_node,
0280 const node_map<edge>& prev_edge) const;
0281
0282
0283
0284
0285 void create_back_edge(graph& G, const edge& org_edge);
0286
0287
0288
0289
0290 void comp_max_flow(const graph& G);
0291
0292
0293
0294
0295 void restore_graph(graph& G);
0296 private:
0297 };
0298
0299 __GTL_END_NAMESPACE
0300
0301 #endif
0302
0303
0304
0305