private static void expandCluster(IEnumerable <DBScanPoint> points, DBScanPoint p, IEnumerable <DBScanPoint> neighborPoints, int clusterCount, double eps, int minPoints) { p.id = clusterCount; IEnumerable <DBScanPoint> neighbors; for (int i = 0; i < neighborPoints.Count(); i++) { var pointNeighbor = neighborPoints.ElementAt(i); if (!pointNeighbor.visited) { pointNeighbor.visited = true; neighbors = findNeighbours(points, pointNeighbor, eps); if (neighbors.Count() >= minPoints) { neighborPoints = neighborPoints.Union(neighbors).ToArray(); } } if (pointNeighbor.id == 0) // not classified { pointNeighbor.id = clusterCount; } } }
private static IEnumerable <DBScanPoint> findNeighbours(IEnumerable <DBScanPoint> points, DBScanPoint p, double eps) { var neighborPoints = points.Where(x => Math.Abs(x.value - p.value) <= eps); return(neighborPoints); }