diff --git a/cpp/src/hdbscan/runner.h b/cpp/src/hdbscan/runner.h index ff7ec71f66..bffa0777af 100644 --- a/cpp/src/hdbscan/runner.h +++ b/cpp/src/hdbscan/runner.h @@ -71,7 +71,13 @@ struct FixConnectivitiesRedOp { if (rit < m && a.key > -1 && colors[rit] != colors[a.key]) { value_t core_dist_rit = core_dists[rit]; value_t core_dist_a = max(core_dist_rit, max(core_dists[a.key], a.value)); - value_t core_dist_b = max(core_dist_rit, max(core_dists[b.key], b.value)); + + value_t core_dist_b; + if (b.key > -1) { + core_dist_b = max(core_dist_rit, max(core_dists[b.key], b.value)); + } else { + core_dist_b = b.value; + } return core_dist_a < core_dist_b ? KVP(a.key, core_dist_a) : KVP(b.key, core_dist_b);