min_tree.h

00001 //==========================================================================
00002 //
00003 //   min_tree.cpp
00004 //
00005 //==========================================================================
00006 // $Id: min_tree.h,v 1.3 2001/06/21 10:55:08 chris Exp $
00007 
00008 #ifndef GTL_MIN_TREE_H
00009 #define GTL_MIN_TREE_H
00010 
00011 #include <GTL/GTL.h>
00012 #include <GTL/algorithm.h>
00013 #include <GTL/edge_map.h>
00014 #include <set>
00015 
00016 __GTL_BEGIN_NAMESPACE
00017 
00024 class min_tree: public algorithm { 
00025 
00026 public:
00027 
00031     min_tree ();
00032 
00036     virtual ~min_tree () {};
00037 
00053     int check (graph& g);
00054 
00055     int run (graph& g);
00056     
00057     virtual void reset ();
00058 
00067     void set_distances (const edge_map<int>& dist);
00068 
00076     set<edge> get_min_tree();
00077     
00083     int get_min_tree_length();
00084     
00085 private:
00086     typedef pair<int, node::adj_edges_iterator> TSP_A_VALUE;
00087 
00088     class input_comp {
00089     public:
00090         bool operator()(TSP_A_VALUE x, TSP_A_VALUE y)
00091             { return x.first > y.first;}
00092     };
00093 
00094     edge_map<int> dist;
00095     int weight;
00096     set<edge> tree;
00097     bool is_set_distances;
00098 };
00099 
00100 __GTL_END_NAMESPACE
00101 
00102 #endif // GTL_MIN_TREE_H
00103 
00104 
00105 
00106 
00107