PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ UF_union()

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

Definition at line 85 of file lwunionfind.c.

86 {
87  uint32_t a = UF_find(uf, i);
88  uint32_t b = UF_find(uf, j);
89 
90  if (a == b)
91  {
92  return;
93  }
94 
95  if (uf->cluster_sizes[a] < uf->cluster_sizes[b] ||
96  (uf->cluster_sizes[a] == uf->cluster_sizes[b] && a > b))
97  {
98  uf->clusters[a] = uf->clusters[b];
99  uf->cluster_sizes[b] += uf->cluster_sizes[a];
100  uf->cluster_sizes[a] = 0;
101  }
102  else
103  {
104  uf->clusters[b] = uf->clusters[a];
105  uf->cluster_sizes[a] += uf->cluster_sizes[b];
106  uf->cluster_sizes[b] = 0;
107  }
108 
109  uf->num_clusters--;
110 }
uint32_t UF_find(UNIONFIND *uf, uint32_t i)
Definition: lwunionfind.c:62
uint32_t * cluster_sizes
Definition: lwunionfind.h:34
uint32_t * clusters
Definition: lwunionfind.h:33
uint32_t num_clusters
Definition: lwunionfind.h:35

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().

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