PostGIS  2.2.7dev-r@@SVN_REVISION@@
void UF_union ( UNIONFIND uf,
uint32_t  i,
uint32_t  j 
)

Definition at line 65 of file lwunionfind.c.

References UNIONFIND::cluster_sizes, UNIONFIND::clusters, UNIONFIND::num_clusters, and UF_find().

Referenced by test_unionfind_union(), union_if_dwithin(), and union_if_intersecting().

66 {
67  uint32_t a = UF_find(uf, i);
68  uint32_t b = UF_find(uf, j);
69 
70  if (a == b)
71  {
72  return;
73  }
74 
75  if (uf->cluster_sizes[a] < uf->cluster_sizes[b] ||
76  (uf->cluster_sizes[a] == uf->cluster_sizes[b] && a > b))
77  {
78  uf->clusters[a] = uf->clusters[b];
79  uf->cluster_sizes[b] += uf->cluster_sizes[a];
80  uf->cluster_sizes[a] = 0;
81  }
82  else
83  {
84  uf->clusters[b] = uf->clusters[a];
85  uf->cluster_sizes[a] += uf->cluster_sizes[b];
86  uf->cluster_sizes[b] = 0;
87  }
88 
89  uf->num_clusters--;
90 }
uint32_t * clusters
Definition: lwunionfind.h:20
uint32_t * cluster_sizes
Definition: lwunionfind.h:21
uint32_t UF_find(UNIONFIND *uf, uint32_t i)
Definition: lwunionfind.c:48
uint32_t num_clusters
Definition: lwunionfind.h:22

Here is the call graph for this function:

Here is the caller graph for this function: