31 #include <boost/shared_ptr.hpp>
33 #include "../exceptions/WOutOfBounds.h"
34 #include "WUnionFind.h"
39 for(
size_t i = 0; i < size; ++i )
49 throw WOutOfBounds( std::string(
"Element index in UnionFind greater than overall elements!" ) );
64 throw WOutOfBounds( std::string(
"Element index in UnionFind greater than overall elements!" ) );
71 size_t ci =
find( i );
72 size_t cj =
find( j );
84 std::map< size_t, std::set< size_t > > sets;
85 size_t maxSetSizeSoFar = 0;
86 size_t maxSetElement = 0;
89 size_t cE =
find( i );
90 sets[ cE ].insert( i );
91 if( sets[ cE ].size() > maxSetSizeSoFar )
93 maxSetSizeSoFar = sets[ cE ].size();
97 return boost::shared_ptr< std::set< size_t > >(
new std::set< size_t >( sets[ maxSetElement ] ) );