2020-11-19 12:12:00 +01:00
|
|
|
clusternum <- function(X, T, k, c) {
|
|
|
|
|
m <- size(X, 1) + 1
|
2021-05-20 09:18:05 +02:00
|
|
|
while (!isempty(k)) {
|
|
|
|
|
# Get the children of nodes at this level
|
2020-11-19 12:12:00 +01:00
|
|
|
children <- X[k, 1:2]
|
|
|
|
|
|
2021-05-20 09:18:05 +02:00
|
|
|
# Assign this node number to leaf children
|
2020-11-19 12:12:00 +01:00
|
|
|
t <- (children <= m)
|
2021-05-20 09:18:05 +02:00
|
|
|
T[children[t]] <- c
|
|
|
|
|
# Move to next level
|
|
|
|
|
k <- children[!t] - m
|
2020-11-19 12:12:00 +01:00
|
|
|
}
|
|
|
|
|
return(T)
|
2021-05-20 09:18:05 +02:00
|
|
|
}
|