Esempio n. 1
0
 private void ExpandCluster(ScanPoint corePoint, List <ScanPoint> nearPoint, int clusterNum, double radius, int minPts)
 {
     corePoint.PointType  = PointType.Core;
     corePoint.ClusterNum = clusterNum;
     foreach (var p in nearPoint)
     {
         if (p.VisitedType == VisitedType.Unvisited)
         {
             p.VisitedType = VisitedType.Visited;
             List <ScanPoint> neighborPoints = GetRegionPoints(p, radius);
             if (neighborPoints.Count >= minPts)
             {
                 ExpandCluster(p, neighborPoints, clusterNum, radius, minPts);
             }
             else
             {
                 p.PointType  = PointType.Edge;
                 p.ClusterNum = clusterNum;
             }
         }
         else
         {
             if (p.ClusterNum < 0)
             {
                 p.PointType  = PointType.Edge;
                 p.ClusterNum = clusterNum;
             }
         }
     }
 }
Esempio n. 2
0
        private List <ScanPoint> GetRegionPoints(ScanPoint corePoint, double radius)
        {
            List <ScanPoint> result      = new List <ScanPoint>();
            List <ScanPoint> otherPoints = _allPoints.Except(new List <ScanPoint>()
            {
                corePoint
            }).ToList();

            foreach (var p in otherPoints)
            {
                if (_calculateDistance(corePoint, p) <= radius)
                {
                    result.Add(p);
                }
            }
            return(result);
        }