CluE  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
averageinterclusterdistance.h
Go to the documentation of this file.
1 #ifndef AVERAGEINTERCLUSTERDISTANCE_H
2 #define AVERAGEINTERCLUSTERDISTANCE_H
3 
4 #include <cmath>
5 
6 #include "../base/dissimilaritymeasure.h"
7 #include "../base/euclideanspaceprovider.h"
8 #include "../clustering/cfentry.h"
9 
10 namespace CluE
11 {
16 template<typename T> class CFAverageInterClusterDistance : public DissimilarityMeasure<CFEntry<T> >
17 {
18 public:
23 
24  virtual CFAverageInterClusterDistance* clone() const;
25 
29  virtual double dissimilarity(CFEntry<T> const&, CFEntry<T> const&) const;
30 
31 private:
33 };
34 
36  esp(esp->clone())
37 {
38 }
39 
41  esp(aicd.esp->clone())
42 {
43 }
44 
46 {
47  if(esp != 0)
48  delete esp;
49 
50  DissimilarityMeasure<CFEntry<T> >::operator= (aicd);
51 
52  esp = aicd.esp == 0 ? 0 : aicd.esp->clone();
53 
54  return *this;
55 }
56 
58 {
59  if(esp != 0)
60  delete esp;
61 }
62 
64 {
65  return new CFAverageInterClusterDistance<T>(*this);
66 }
67 
68 template<typename T> double CFAverageInterClusterDistance<T>::dissimilarity(CFEntry<T> const& cf1, CFEntry<T> const& cf2) const
69 {
70  double numerator = (cf2.number*cf1.SS - 2*(cf1.LS*cf2.LS) + cf1.number*cf2.SS);
71  double denominator = cf1.number * cf2.number;
72  return std::pow(numerator / denominator, 0.5);
73 }
74 
75 }
76 
77 #endif
double SS
Squared sum.
Definition: cfentry.h:37
virtual double dissimilarity(CFEntry< T > const &, CFEntry< T > const &) const
Computes the average inter cluster distance between the two given CFEntry objects.
CFAverageInterClusterDistance< T > & operator=(const CFAverageInterClusterDistance< T > &)
CFAverageInterClusterDistance(EuclideanSpaceProvider< T > *esp)
T LS
Linear sum.
Definition: cfentry.h:32
size_t number
Number of points contained in the feature.
Definition: cfentry.h:27
Calculates the average inter-cluster distance D2 of a given CFEntry.
virtual CFAverageInterClusterDistance * clone() const
Abstract base class for dissimilarity measurement.
Clustering feature tree entry.
Definition: cfentry.h:22
virtual EuclideanSpaceProvider< V > * clone() const =0