KMeansTree
KMeansTree(points, numberofclusters; ...) builds a BoundingBallTree by recursively partitioning points with k-means.
Construction outline:
- A root cluster is fitted and the root center/radius are initialized.
- Each node is split with k-means into
numberofclusterschild clusters whilelength(values(node)) >= max(minvalues, numberofclusters). - Children store point indices and their local center/radius.
- Internal-node point lists are emptied after splitting, and node ordering is adjusted.
- Node radii are finalized via
updateradii!(default:boundingsphere).
If you use updateradii=H2Trees.unsafemaxradiusboundingsphere or updateradii=H2Trees.noboundingsphereupdate, the radii are not reliably updated. This can lead to incorrect results when using iterators in H2Trees. Proceed at your own risk.
using CompScienceMeshes
using H2Trees
using PlotlyJS
using ParallelKMeans
m = meshsphere(1.0, 0.1)
tree = KMeansTree(vertices(m), 4; minvalues=60)using CompScienceMeshes
using H2Trees
using PlotlyJS
using ParallelKMeans
m = meshsphere(1.0, 0.1)
tree = KMeansTree(
vertices(m),
4;
minvalues=60,
updateradii=H2Trees.noboundingsphereupdate,
)using CompScienceMeshes
using H2Trees
using PlotlyJS
using ParallelKMeans
m = meshsphere(1.0, 0.1)
tree = KMeansTree(
vertices(m),
4;
minvalues=60,
updateradii=H2Trees.unsafemaxradiusboundingsphere
)