00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPSTATISTICS_KM_CENTERS_NODE_H
00009 #define IMPSTATISTICS_KM_CENTERS_NODE_H
00010
00011 #include "KMData.h"
00012 #include "KMRectangle.h"
00013 #include "KMCenters.h"
00014 IMPSTATISTICS_BEGIN_NAMESPACE
00015
00016 #ifndef IMP_DOXYGEN
00017
00018
00019
00020
00021
00022
00023
00024
00025 class IMPSTATISTICSEXPORT KMCentersNode {
00026 public:
00027 KMCentersNode(){}
00028
00029
00030
00031
00032 KMCentersNode(const KMRectangle &bb, KMCenters *centers,int level);
00033 virtual ~KMCentersNode();
00034
00035
00036
00037
00038 int get_subtree_size() { return 2*n_data_ - 1; }
00039 int get_number_of_data_points() { return n_data_; }
00040
00041 KMPoint get_mid_point() const;
00042 KMRectangle &get_bounding_box()
00043 { return bnd_box_; }
00044
00045 virtual void compute_sums()=0;
00046 const KMPoint * get_sums() const {return &sum_;}
00047 double get_sum_sq() const {return sum_sq_;}
00048
00049 virtual void get_neighbors(const std::vector<int> &cands,
00050 KMPointArray *sums, KMPoint *sum_sqs,std::vector<int> *weights)=0;
00051
00052 virtual void get_assignments(const std::vector<int> &cands,
00053 std::vector<int> &close_center)=0;
00054
00055 virtual KMPoint sample_center()=0;
00056
00057 virtual void show(std::ostream&out=std::cout) const =0;
00058 protected:
00059
00060
00061
00062
00063 int mid_center(const std::vector<int> &cands);
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 void compute_close_centers(
00076 const std::vector<int> &candidate_centers_inds,
00077 std::vector<int> *close_centers_inds);
00078
00079 void post_neighbor(KMPointArray *sums, KMPoint *sum_sqs,
00080 std::vector<int> *weights,int center_ind);
00081
00082 void post_one_neighbor(KMPointArray *sums, KMPoint *sum_sqs,
00083 std::vector<int> *weights,int center_ind, const KMPoint &p);
00084 int n_data_;
00085 KMPoint sum_;
00086 double sum_sq_;
00087 KMRectangle bnd_box_;
00088 KMCenters *centers_;
00089 int level_;
00090 };
00091
00092 #endif
00093
00094 IMPSTATISTICS_END_NAMESPACE
00095 #endif