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

- Main Page
- Classes
- Files
- Related Pages

# fm_partition.h

    00001 //==========================================================================
    00002 //
    00003 //      fm_partition.h
    00004 //
    00005 //==========================================================================
    00006 // $Id: fm_partition.h,v 1.8 2003/01/31 08:15:05 chris Exp $
    00007
    00008 #ifndef GTL_FM_PARTITION_H
    00009 #define GTL_FM_PARTITION_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 __GTL_BEGIN_NAMESPACE
    00018
    00019
    00032 class GTL_EXTERN fm_partition : public algorithm
    00033 {
    00034 public:
    00041     typedef int side_type;
    00042
    00048     const static side_type A;
    00049
    00055     const static side_type B;
    00056
    00064     typedef short int fix_type;
    00065
    00071     const static fix_type FIXA;
    00072
    00078     const static fix_type FIXB;
    00079
    00085     const static fix_type UNFIXED;
    00086
    00092     fm_partition();
    00093
    00099     virtual ~fm_partition();
    00100
    00110     void set_vars(const graph& G, const node_map<int>& node_weight,
    00111         const edge_map<int>& edge_weight);
    00112
    00125     void set_vars(const graph& G, const node_map<int>& node_weight,
    00126         const edge_map<int>& edge_weight,
    00127         const node_map<side_type>& init_side);
    00128
    00139     void set_vars(const graph& G, const node_map<int>& node_weight,
    00140         const edge_map<int>& edge_weight,
    00141         const node_map<fix_type>& fixed);
    00142
    00157     void set_vars(const graph& G, const node_map<int>& node_weight,
    00158         const edge_map<int>& edge_weight,
    00159         const node_map<side_type>& init_side,
    00160         const node_map<fix_type>& fixed);
    00161
    00171     void store_cut_edges(const bool set);
    00172
    00184     void store_nodesAB(const bool set);
    00185
    00201     virtual int check(graph& G);
    00202
    00213     int run(graph& G);
    00214
    00220     int get_cutsize();
    00221
    00228     int get_needed_passes();
    00229
    00237     side_type get_side_of_node(const node& n) const;
    00238
    00247     side_type operator [](const node& n) const;
    00248
    00255     int get_weight_on_sideA(const graph& G) const;
    00256
    00263     int get_weight_on_sideB(const graph& G) const;
    00264
    00268     typedef list<edge>::const_iterator cut_edges_iterator;
    00269
    00278     cut_edges_iterator cut_edges_begin() const;
    00279
    00288     cut_edges_iterator cut_edges_end() const;
    00289
    00293     typedef list<node>::const_iterator nodes_of_one_side_iterator;
    00294
    00302     nodes_of_one_side_iterator nodes_of_sideA_begin() const;
    00303
    00312     nodes_of_one_side_iterator nodes_of_sideA_end() const;
    00313
    00321     nodes_of_one_side_iterator nodes_of_sideB_begin() const;
    00322
    00331     nodes_of_one_side_iterator nodes_of_sideB_end() const;
    00332
    00339     virtual void reset();
    00340 protected:
    00346     bool enable_cut_edges_storing;
    00347
    00352     list<edge> cut_edges;
    00353
    00359     bool enable_nodesAB_storing;
    00360
    00365     list<node> nodesA;
    00366
    00371     list<node> nodesB;
    00372
    00379     bool set_vars_executed;
    00380
    00386     bool provided_initial_part;
    00387
    00393     bool provided_fix;
    00394
    00399     node_map<fix_type> fixed;
    00400
    00406     node_map<int> node_weight;
    00407
    00413     int max_node_weight;
    00414
    00420     edge_map<int> edge_weight;
    00421
    00427     int max_edge_weight;
    00428
    00434     int total_node_weight;
    00435
    00441     int node_weight_on_sideA;
    00442
    00448     int node_weight_on_sideB;
    00449
    00454     node_map<side_type> side;
    00455
    00460     node_map<list<node>::iterator> position_in_bucket;
    00461
    00466     int max_vertex_degree;
    00467
    00472     edge_map<int> aside;
    00473
    00478     edge_map<int> bside;
    00479
    00485     edge_map<list<node> > unlockedA;
    00486
    00492     edge_map<list<node> > unlockedB;
    00493
    00498     node_map<int> gain_value;
    00499
    00504     bool bucketA_empty;
    00505
    00510     bool bucketB_empty;
    00511
    00517     int max_gainA;
    00518
    00524     int max_gainB;
    00525
    00532     vector<list<node> > bucketA;
    00533
    00540     vector<list<node> > bucketB;
    00541
    00547     int cur_cutsize;
    00548
    00553     int no_passes;
    00554
    00560     void divide_up(const graph& G);
    00561
    00566     void hide_self_loops(graph& G);
    00567
    00573     void init_variables(const graph& G);
    00574
    00581     void create_initial_bipart(const graph& G);
    00582
    00588     void shuffle_vector(const int vector_size,
    00589         vector<graph::node_iterator>& node_vector);
    00590
    00595     void compute_max_vertex_degree(const graph& G);
    00596
    00601     void pass_manager(const graph& G);
    00602
    00607     void copy_side_node_map(const graph& G, node_map<side_type>& dest,
    00608         const node_map<side_type> source) const;
    00609
    00614     void init_data_structure(const graph& G);
    00615
    00621     void init_filling_buckets(const graph& G);
    00622
    00628     int inital_gain_of_node_on_sideA(const node cur_node);
    00629
    00635     int inital_gain_of_node_on_sideB(const node cur_node);
    00636
    00641     void move_manager(const graph& G);
    00642
    00649     bool move_vertex(const graph& G, node& moved_node);
    00650
    00657     bool balance_holds(const graph& G, const node cur_node);
    00658
    00664     void update_data_structure_A2B(const node cur_node);
    00665
    00671     void update_data_structure_B2A(const node cur_node);
    00672
    00678     void update_bucketA(const node cur_node, const int old_gain,
    00679         const int new_gain);
    00680
    00686     void update_bucketB(const node cur_node, const int old_gain,
    00687         const int new_gain);
    00688
    00694     void update_max_gain(const side_type side);
    00695
    00701     inline int range_up(const int gain_value) const;
    00702
    00708     inline int range_down(const int index) const;
    00709
    00714     void clean_pass(const graph& G);
    00715
    00720     void compute_cut_edges(const graph& G);
    00721
    00726     void compute_nodesAB(const graph& G);
    00727 private:
    00728 #ifdef _DEBUG
    00729
    00733     void print_bucketA();
    00734
    00739     void print_bucketB();
    00740 #endif  // _DEBUG
    00741 };
    00742
    00743
    00744 __GTL_END_NAMESPACE
    00745
    00746 #endif // GTL_FM_PARTITION_H
    00747
    00748 //--------------------------------------------------------------------------
    00749 //   end of file
    00750 //--------------------------------------------------------------------------

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau