所以,是的......它的错误。鉴于代码,我不知道我缺少什么或没有做到让它工作:
RegionQuery(allPointsDbscan, p.ClusterPoint, epsilon, deltaX, deltaY, out neighborPts);
if (neighborPts != null)
{
if (neighborPts.Length < minPts)
p.ClusterId = (int)ClusterIds.Noise;
else
{
clusterId++;
ExpandCluster(allPointsDbscan, p, neighborPts, clusterId, epsilon, minPts, deltaX, deltaX);
}
}
private void RegionQuery(DbscanPoint[] allPoints, DatasetItem point, double epsilon, double delta_X, double delta_Y, out DbscanPoint[] neighborPts)
{
if (delta_X < 0.1499 && delta_Y < 0.0899)
{
neighborPts = allPoints.Where(x => _metricFunc(point, x.ClusterPoint) <= epsilon).ToArray();
}
else
neighborPts = null;
}
我不明白为什么它会抛弃我的异常,因为在我对它做任何事情之前,我会检查neighborPts
是否NULL
;但似乎我甚至不能这样做。这是为什么?