From c49d1033bc45d05a08a5592d9e2a8bae32d502aa Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 29 May 2018 03:54:58 +0200 Subject: [PATCH] Added Cluster.removePoint(point) for convenience --- cluster.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cluster.go b/cluster.go index a960936..8b82bc4 100644 --- a/cluster.go +++ b/cluster.go @@ -26,6 +26,18 @@ func (c Clusters) Nearest(point Point) int { return ci } +// removePoint removes a point's assignment to this cluster +func (c *Cluster) removePoint(p Point) { + var pp Points + for _, v := range c.Points { + if !v.Equal(p) { + pp = append(pp, p) + } + } + + c.Points = pp +} + // recenter recenters a cluster func (c *Cluster) recenter() { center, err := c.Points.Mean()