147{
149 uint32_t* new_ids =
lwalloc(uf->
N *
sizeof(uint32_t));
150 uint32_t last_old_id, current_new_id, i;
151 char encountered_cluster =
LW_FALSE;
152
153 current_new_id = 0; last_old_id = 0;
154 for (i = 0; i < uf->
N; i++)
155 {
156 uint32_t j = ordered_components[i];
157 if (!is_in_cluster || is_in_cluster[j])
158 {
159 uint32_t current_old_id =
UF_find(uf, j);
160 if (!encountered_cluster)
161 {
163 last_old_id = current_old_id;
164 }
165
166 if (current_old_id != last_old_id)
167 current_new_id++;
168
169 new_ids[j] = current_new_id;
170 last_old_id = current_old_id;
171 }
172 }
173
174 lwfree(ordered_components);
175
176 return new_ids;
177}
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
uint32_t UF_find(UNIONFIND *uf, uint32_t i)
uint32_t * UF_ordered_by_cluster(UNIONFIND *uf)