From 846611cc7ed76ce20c282ddd1623169c403f68e8 Mon Sep 17 00:00:00 2001 From: divyegala Date: Tue, 13 Jul 2021 13:33:48 -0700 Subject: [PATCH] fixing -1 key access in 1nn reduce op --- cpp/src/hdbscan/runner.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpp/src/hdbscan/runner.h b/cpp/src/hdbscan/runner.h index c66b0560ea..dca0f2f04c 100644 --- a/cpp/src/hdbscan/runner.h +++ b/cpp/src/hdbscan/runner.h @@ -58,7 +58,13 @@ struct FixConnectivitiesRedOp { colors[rit] != colors[other.key]) { value_t core_dist_rit = core_dists[rit]; value_t core_dist_other = max(core_dist_rit, max(core_dists[other.key], other.value)); - value_t core_dist_out = max(core_dist_rit, max(core_dists[out->key], out->value)); + + value_t core_dist_out; + if (out->key > -1) { + core_dist_out = max(core_dist_rit, max(core_dists[out->key], out->value)); + } else { + core_dist_out = out->value; + } bool smaller = core_dist_other < core_dist_out; out->key = smaller ? other.key : out->key;