PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ UF_union()

void UF_union ( UNIONFIND uf,
uint32_t  i,
uint32_t  j 
)

Definition at line 84 of file lwunionfind.c.

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

Referenced by test_unionfind_union(), union_dbscan_minpoints_1(), union_if_available(), and union_intersecting_pairs().

85 {
86  uint32_t a = UF_find(uf, i);
87  uint32_t b = UF_find(uf, j);
88 
89  if (a == b)
90  {
91  return;
92  }
93 
94  if (uf->cluster_sizes[a] < uf->cluster_sizes[b] ||
95  (uf->cluster_sizes[a] == uf->cluster_sizes[b] && a > b))
96  {
97  uf->clusters[a] = uf->clusters[b];
98  uf->cluster_sizes[b] += uf->cluster_sizes[a];
99  uf->cluster_sizes[a] = 0;
100  }
101  else
102  {
103  uf->clusters[b] = uf->clusters[a];
104  uf->cluster_sizes[a] += uf->cluster_sizes[b];
105  uf->cluster_sizes[b] = 0;
106  }
107 
108  uf->num_clusters--;
109 }
uint32_t * clusters
Definition: lwunionfind.h:33
uint32_t * cluster_sizes
Definition: lwunionfind.h:34
unsigned int uint32_t
Definition: uthash.h:78
uint32_t UF_find(UNIONFIND *uf, uint32_t i)
Definition: lwunionfind.c:61
uint32_t num_clusters
Definition: lwunionfind.h:35
Here is the call graph for this function:
Here is the caller graph for this function: