28 m_num_elements = num_elements;
33 void CDisjointSet::init()
40 m_is_connected =
false;
46 REQUIRE(m_num_elements > 0,
"%s::make_sets(): m_num_elements <= 0.\n",
get_name());
54 ASSERT(x >= 0 && x < m_num_elements);
65 ASSERT(xroot >= 0 && xroot < m_num_elements);
66 ASSERT(yroot >= 0 && yroot < m_num_elements);
67 ASSERT(m_parent[xroot] == xroot && m_parent[yroot] == yroot);
71 if (m_rank[xroot] > m_rank[yroot])
73 m_parent[yroot] = xroot;
78 m_parent[xroot] = yroot;
79 if (m_rank[xroot] == m_rank[yroot])
88 ASSERT(x >= 0 && x < m_num_elements);
89 ASSERT(y >= 0 && y < m_num_elements);
103 ASSERT(x >= 0 && x < m_num_elements);
104 ASSERT(y >= 0 && y < m_num_elements);
114 REQUIRE(m_num_elements > 0,
"%s::get_unique_labeling(): m_num_elements <= 0.\n",
get_name());
116 if (out_labels.
size() != m_num_elements)
122 int32_t unilabel = 0;
124 for (int32_t i = 0; i < m_num_elements; i++)
128 if (flags[roots[i]] < 0)
129 flags[roots[i]] = unilabel++;
132 for (int32_t i = 0; i < m_num_elements; i++)
133 out_labels[i] = flags[roots[i]];
140 REQUIRE(m_num_elements > 0,
"%s::get_num_sets(): m_num_elements <= 0.\n",
get_name());
147 return m_is_connected;
152 m_is_connected = is_connected;
void range_fill(T start=0)
virtual const char * get_name() const
bool union_set(int32_t x, int32_t y)
static void fill_vector(T *vec, int32_t len, T value)
Class SGObject is the base class of all shogun objects.
int32_t get_unique_labeling(SGVector< int32_t > out_labels)
all of classes and functions are contained in the shogun namespace
void set_connected(bool is_connected)
bool is_same_set(int32_t x, int32_t y)
void resize_vector(int32_t n)
int32_t link_set(int32_t xroot, int32_t yroot)
int32_t find_set(int32_t x)
#define SG_UNSTABLE(func,...)