Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History
00001 //========================================================================== 00002 // 00003 // maxflow_ff.h 00004 // 00005 //========================================================================== 00006 // $Id: maxflow_ff.h,v 1.5 2003/01/31 08:15:05 chris Exp $ 00007 00008 #ifndef GTL_MAXFLOW_FF_H 00009 #define GTL_MAXFLOW_FF_H 00010 00011 #include <GTL/GTL.h> 00012 #include <GTL/graph.h> 00013 #include <GTL/node_map.h> 00014 #include <GTL/edge_map.h> 00015 #include <GTL/algorithm.h> 00016 00017 #include <queue> 00018 00019 __GTL_BEGIN_NAMESPACE 00020 00024 class GTL_EXTERN maxflow_ff : public algorithm 00025 { 00026 public: 00033 maxflow_ff(); 00034 00040 virtual ~maxflow_ff(); 00041 00049 void set_vars(const edge_map<double>& edge_capacity); 00050 00058 void set_vars( 00059 const edge_map<double>& edge_capacity, 00060 const node& net_source, 00061 const node& net_target); 00062 00080 virtual int check(graph& G); 00081 00090 int run(graph& G); 00091 00098 double get_max_flow(const edge& e) const; 00099 00105 double get_max_flow() const; 00106 00113 double get_rem_cap(const edge& e) const; 00114 00121 virtual void reset(); 00122 protected: 00126 enum {SP_FOUND = 2, NO_SP_FOUND = 3}; 00127 00131 bool artif_source_target; 00132 00136 bool set_vars_executed; 00137 00141 double max_graph_flow; 00142 00146 node net_source; 00147 00151 node net_target; 00152 00156 list<edge> edges_not_org; 00157 00161 edge_map<bool> edge_org; 00162 00166 edge_map<bool> back_edge_exists; 00167 00171 edge_map<edge> back_edge; 00172 00176 edge_map<double> edge_capacity; 00177 00181 edge_map<double> edge_max_flow; 00182 00186 void create_artif_source_target(graph& G); 00187 00191 void prepare_run(const graph& G); 00192 00196 void comp_single_flow(graph& G, node_map<edge>& last_edge); 00197 00201 int get_sp(const graph& G, node_map<edge>& last_edge); 00202 00206 int comp_sp( 00207 const graph& G, 00208 queue<node>& next_nodes, 00209 node_map<bool>& visited, 00210 node_map<edge>& last_edge); 00211 00215 double extra_charge(const node_map<edge>& last_edge) const; 00216 00220 void create_back_edge(graph& G, const edge& org_edge); 00221 00225 void comp_max_flow(const graph& G); 00226 00230 void restore_graph(graph& G); 00231 }; 00232 00233 __GTL_END_NAMESPACE 00234 00235 #endif // GTL_MAXFLOW_FF_H 00236 00237 //-------------------------------------------------------------------------- 00238 // end of file 00239 //--------------------------------------------------------------------------
University of Passau - FMI - Theoretical Computer Science