Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History

- Main Page
- Classes
- Files
- Related Pages

# maxflow_sap.h

    00001 //==========================================================================
    00002 //
    00003 //   maxflow_sap.h
    00004 //
    00005 //==========================================================================
    00006 // $Id: maxflow_sap.h,v 1.4 2003/01/31 08:15:05 chris Exp $
    00007
    00008 #ifndef GTL_MAXFLOW_SAP_H
    00009 #define GTL_MAXFLOW_SAP_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
    00033 class GTL_EXTERN maxflow_sap : public algorithm
    00034 {
    00035 public:
    00042     maxflow_sap();
    00043
    00049     virtual ~maxflow_sap();
    00050
    00058     void set_vars(const edge_map<double>& edge_capacity);
    00059
    00067     void set_vars(const edge_map<double>& edge_capacity,
    00068                                   const node& net_source,
    00069                                   const node& net_target);
    00070
    00088     virtual int check(graph& G);
    00089
    00098     int run(graph& G);
    00099
    00106     double get_max_flow(const edge& e) const;
    00107
    00113     double get_max_flow() const;
    00114
    00121     double get_rem_cap(const edge& e) const;
    00122
    00129     virtual void reset();
    00130 protected:
    00134     enum {AP_FOUND = 2, NO_AP_FOUND = 3};
    00135
    00139     bool artif_source_target;
    00140
    00144     bool set_vars_executed;
    00145
    00149     double max_graph_flow;
    00150
    00154     node net_source;
    00155
    00159     node net_target;
    00160
    00164     list<edge> edges_not_org;
    00165
    00169     node_map<int> dist_label;
    00170
    00174     edge_map<bool> edge_org;
    00175
    00179     edge_map<bool> back_edge_exists;
    00180
    00184     edge_map<edge> back_edge;
    00185
    00189     edge_map<double> edge_capacity;
    00190
    00194     edge_map<double> edge_max_flow;
    00195
    00199     void create_artif_source_target(graph& G);
    00200
    00204     void prepare_run(const graph& G);
    00205
    00209         void comp_dist_labels(const graph& G, vector<int>& numb);
    00210
    00214         bool has_an_admissible_arc(const node cur_node);
    00215
    00219         void advance(node& cur_node, node_map<edge>& last_edge);
    00220
    00224         void augment(graph& G, const node_map<edge>& last_edge);
    00225
    00229         bool retreat(const int number_of_nodes,
    00230                                  node& cur_node,
    00231                                  const node_map<edge>& last_edge,
    00232                                  vector<int>& numb);
    00233
    00237         int min_neighbour_label(const int number_of_nodes,
    00238                                                         const node cur_node) const;
    00239
    00243     double free_capacity(const node_map<edge>& last_edge) const;
    00244
    00248     void create_back_edge(graph& G, const edge& org_edge);
    00249
    00253     void comp_max_flow(const graph& G);
    00254
    00258     void restore_graph(graph& G);
    00259 };
    00260
    00261 __GTL_END_NAMESPACE
    00262
    00263 #endif // GTL_MAXFLOW_SAP_H
    00264
    00265 //--------------------------------------------------------------------------
    00266 //   end of file
    00267 //--------------------------------------------------------------------------

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau