PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_unionfind_path_compression()

static void test_unionfind_path_compression ( void  )
static

Definition at line 90 of file cu_unionfind.c.

91 {
92  UNIONFIND* uf = UF_create(5);
93  uint32_t i;
94 
95  uf->clusters[1] = 0;
96  uf->clusters[2] = 1;
97  uf->clusters[3] = 2;
98  uf->clusters[4] = 3;
99 
100  /* Calling "find" on a leaf should attach all nodes between the root and the
101  * leaf directly to the root. */
102  uint32_t root = UF_find(uf, 4);
103  for (i = 0; i < uf->N; i++)
104  {
105  /* Verify that all cluster references have been updated to point
106  * directly to the root. */
107  CU_ASSERT_EQUAL(root, uf->clusters[i]);
108  }
109 
110  UF_destroy(uf);
111 }
void UF_destroy(UNIONFIND *uf)
Definition: lwunionfind.c:53
uint32_t UF_find(UNIONFIND *uf, uint32_t i)
Definition: lwunionfind.c:61
UNIONFIND * UF_create(uint32_t N)
Definition: lwunionfind.c:34
uint32_t N
Definition: lwunionfind.h:36
uint32_t * clusters
Definition: lwunionfind.h:33
unsigned int uint32_t
Definition: uthash.h:78

References UNIONFIND::clusters, UNIONFIND::N, UF_create(), UF_destroy(), and UF_find().

Referenced by unionfind_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: