Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

UnionFindSimple.h

Go to the documentation of this file.
00001 #ifndef UNIONFINDSIMPLE_H
00002 #define UNIONFINDSIMPLE_H
00003 
00004 #include <vector>
00005 
00006 namespace AprilTags {
00007 
00008 //! Implementation of disjoint set data structure using the union-find algorithm
00009 class UnionFindSimple {
00010   //! Identifies parent ids and sizes.
00011   struct Data {
00012     int id;
00013     int size;
00014   };
00015 
00016 public:
00017   explicit UnionFindSimple(int maxId) : data(maxId) {
00018     init();
00019   };
00020   
00021   int getSetSize(int thisId) { return data[getRepresentative(thisId)].size; }
00022 
00023   int getRepresentative(int thisId);
00024 
00025   //! Returns the id of the merged node.
00026   /*  @param aId
00027    *  @param bId
00028    */
00029   int connectNodes(int aId, int bId);
00030 
00031   void printDataVector() const;
00032 
00033 private:
00034   void init();
00035   
00036   std::vector<Data> data;
00037 };
00038 
00039 } // namespace
00040 
00041 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:52 2016 by Doxygen 1.6.3