diff options
Diffstat (limited to 'meowpp/dsa/DisjointSet.h')
-rw-r--r-- | meowpp/dsa/DisjointSet.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/meowpp/dsa/DisjointSet.h b/meowpp/dsa/DisjointSet.h new file mode 100644 index 0000000..1ea6d97 --- /dev/null +++ b/meowpp/dsa/DisjointSet.h @@ -0,0 +1,32 @@ +#ifndef DisjointSet_H__ +#define DisjointSet_H__ + +#include <vector> +#include <cstdlib> + +namespace meow{ + class DisjointSet{ + private: + size_t n; + std::vector<size_t> father; + std::vector<size_t> depth; + // + size_t _root(size_t now); + size_t _merge(size_t a, size_t b); + public: + DisjointSet(); + DisjointSet(size_t _n); + DisjointSet(DisjointSet const& dsj); + // + size_t root (size_t a ) const; + size_t size ( ) const; + // + void reset(size_t _n ); + size_t merge(size_t a, size_t b); + }; +} + +#include "DisjointSet.hpp" + + +#endif // DisjointSet_H__ |