Skip to content

Commit

Permalink
fix updates for min index bookkeeping when linkage is not "single"
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-Lan committed Aug 15, 2023
1 parent 4138746 commit 94afbbc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/hcluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,16 @@ export function hcluster() {

// update dmin and replace ones that previous pointed to c2 to point to c1
for (let j = 0; j < n; j++) {
if (dMin[j] == c2) {
dMin[j] = c1;
if (linkage === 'single') {
if (dMin[j] === c2) {
dMin[j] = c1;
}
} else if (dMin[j] === c2 || dMin[j] === c1) {
for (let k = 0; k < n; k++) {
if (distMatrix[j][k] < distMatrix[j][dMin[j]]) {
dMin[j] = k;
}
}
}
if (distMatrix[c1][j] < distMatrix[c1][dMin[c1]]) {
dMin[c1] = j;
Expand Down

0 comments on commit 94afbbc

Please sign in to comment.