CluE  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
partitionsolution.h
Go to the documentation of this file.
1 #ifndef PARTITIONSOLUTION_H
2 #define PARTITIONSOLUTION_H
3 
4 #include "../base/solutionprovider.h"
5 #include "../base/partitionprovider.h"
6 
7 #include <vector>
8 
9 namespace CluE
10 {
11 
19 template<typename T> struct PartitionSolution : public SolutionProvider,
20  public PartitionProvider<T>
21 {
22 public:
23 
25 
27  {
28  }
29 
30  virtual double computationtime() const;
31  virtual unsigned int number_of_solutions() const;
32  virtual unsigned int size_of_solution(unsigned int) const;
33 
34  virtual unsigned int clustersize(unsigned int, unsigned int) const;
35  virtual T* element(unsigned int, unsigned int, unsigned int) const;
36  virtual std::vector<T*> cluster(unsigned int, unsigned int) const;
37  virtual std::vector<std::vector<T*> > clustering(unsigned int) const;
38 
39  double seconds;
40  std::vector<std::vector<std::vector<T*> > > partitions;
41 };
42 
43 template<typename T> PartitionSolution<T>::PartitionSolution() : seconds()
44 {
45 }
46 
47 template<typename T> double PartitionSolution<T>::computationtime() const
48 {
49  return seconds;
50 }
51 
52 template<typename T> unsigned int PartitionSolution<T>::number_of_solutions() const
53 {
54  return this->partitions.size();
55 }
56 
57 template<typename T> unsigned int PartitionSolution<T>::size_of_solution(unsigned int i) const
58 {
59  if (i<this->partitions.size())
60  return this->partitions[i].size();
61  return 0;
62 }
63 
64 template<typename T> unsigned int PartitionSolution<T>::clustersize(unsigned int g, unsigned int c) const
65 {
66  if (g<this->partitions.size())
67  if (c<this->partitions[g].size())
68  return this->partitions[g][c].size();
69  return 0;
70 }
71 
72 template<typename T> T* PartitionSolution<T>::element(unsigned int g, unsigned int c, unsigned int n) const
73 {
74  if (g<this->partitions.size())
75  if (c<this->partitions[g].size())
76  if (n<this->partitions[g][c].size())
77  return this->partitions[g][c][n];
78  return NULL;
79 }
80 
81 template<typename T> std::vector<T*> PartitionSolution<T>::cluster(unsigned int g, unsigned int c) const
82 {
83  if (g<this->partitions.size())
84  if (c<this->partitions[g].size())
85  return this->partitions[g][c];
86  return std::vector<T*>();
87 }
88 
89 template<typename T> std::vector<std::vector<T*> > PartitionSolution<T>::clustering(unsigned int g) const
90 {
91  if (g<this->partitions.size())
92  return this->partitions[g];
93  return std::vector<std::vector<T*> >();
94 }
95 
96 }
97 
98 #endif
std::vector< std::vector< std::vector< T * > > > partitions
virtual unsigned int size_of_solution(unsigned int) const
returns the size of a particular solution
virtual T * element(unsigned int, unsigned int, unsigned int) const
Returns a pointer to a particular element from the specified cluster and clustering.
virtual std::vector< std::vector< T * > > clustering(unsigned int) const
Returns the specified clustering as a vector of vector of pointers to the elements.
virtual unsigned int number_of_solutions() const
returns the number of available solutions
Abstract base class to access results of partition based clustering algorithms.
virtual unsigned int clustersize(unsigned int, unsigned int) const
Returns the cardinality of the specified cluster from the computed clustering.
Abstract base class for algorithm solutions.
Data structure for partitions.
virtual std::vector< T * > cluster(unsigned int, unsigned int) const
Returns a vector of pointers to the elements of a particular cluster from the specified clustering...
virtual double computationtime() const
returns the time needed for the last computation