Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DAGSearchDatabase.h

Go to the documentation of this file.
00001 
00041 #ifndef __DAGSEARCHDATABASE_H__
00042 #define __DAGSEARCHDATABASE_H__
00043 
00044 #include <set>
00045 #include <string>
00046 #include <list>
00047 #include <map>
00048 #include <vector>
00049 #include <HnSRTree/HnSRTreeFile.hh>
00050 #include "DAG.h"
00051 
00053 typedef int ID;
00054 
00056 const ID NULLID = -1;
00057 
00059 const int  Min_NND_Dimension = 1;
00060 
00062 /*
00063 *This structure is used to contain data in the near neighbour search database
00064 */
00065 struct DAGSearchRecord
00066 {
00067         ID id;          
00068         ID offset;  
00069         ID node;    
00070 
00071         double totalVote;
00072         int nodeLbl;
00073 };
00074 
00075 struct DAGSearchRecordEx : public DAGSearchRecord
00076 {
00077         TSV nodeTSV;
00078 
00079         void operator=(const DAGSearchRecord& rhs)
00080         {
00081                 id = rhs.id;
00082                 offset = rhs.offset;
00083                 node = rhs.node;
00084                 totalVote = rhs.totalVote;
00085                 nodeLbl = rhs.nodeLbl;
00086         }
00087 };
00088 
00090 /*
00091 *This an encupsulating class for a near neigbour search database.
00092 *It defines the interface for functions required by the indexer and
00093 *implements them using an adopted near neighbour search database.
00094 */
00095 class DAGSearchDatabase
00096 {
00098 
00103         class NND
00104         {
00105         public:
00106                 HnSRTreeFile data; 
00107                 std::string name; 
00108                 int dimension; 
00109         } nnd;
00110         
00111 public:
00113         DAGSearchDatabase();
00114         
00116         virtual ~DAGSearchDatabase();
00117 
00119 
00128          void Add(ID id, const DAG& dag);
00129 
00131 
00140         void Remove(ID id, DAG& dag);
00141 
00143 
00149         SmartArray<DAGSearchRecordEx> GetKClosest(const DAG& dag, const leda_node& querynode, int k);
00150 
00152 
00158         SmartArray<DAGSearchRecordEx> GetClosest(const DAG& dag, const leda_node& querynode, const double& range);
00159 
00161 
00168         bool Create(std::string name, int dim);
00169 
00171 
00177         bool Open(std::string name);
00178 
00180 
00187         std::istream& Read(std::istream& is);
00188 
00190 
00196         std::ostream& Write(std::ostream& os);
00197 
00198         void Close();
00199 
00200         int GetDim() const { return nnd.dimension; }
00201 
00202 private:
00203   static HnPoint TSVtoHnPoint(const TSV& tsv);
00204   static TSV HnPointToTSV(const HnPoint& pt);
00205 };
00206 
00207 #endif //__DAGSEARCHDATABASE_H__

Generated on Sat Nov 13 11:21:22 2004 for Noisy DAG Matcher by doxygen1.2.18