コード例 #1
0
        private void ExpandClusterOrder(VectorDataOptics pointDBS)
        {
            var neighbors = kdTree.PointsWithinRadiusOfWithDistance(pointDBS, Epsilon);

            pointDBS.Visited = true;

            pointDBS.ReachabilityDistance = double.PositiveInfinity;

            pointDBS.SetCoreDistance(neighbors, Epsilon, MinPts);

            clusterOrdering.Add(pointDBS);

            if (!double.IsPositiveInfinity(pointDBS.CoreDistance))
            {
                var orderSeeds = new PriorityQueue<VectorDataOptics>();
                Update(neighbors, pointDBS, orderSeeds);
                while (orderSeeds.IsEmpty() == false)
                {
                    var currentObject = orderSeeds
                            .Poll();

                    var neighborsCurrent = kdTree
                            .PointsWithinRadiusOfWithDistance(pointDBS, Epsilon);

                    currentObject.Visited = true;

                    currentObject.SetCoreDistance(neighborsCurrent, Epsilon, MinPts);

                    clusterOrdering.Add(currentObject);

                    if (!double.IsPositiveInfinity(currentObject.CoreDistance))
                    {
                        Update(neighborsCurrent, currentObject, orderSeeds);
                    }
                }
            }
        }
コード例 #2
0
        private void Update(List<KNNPoint> neighbors,
            VectorDataOptics centerObject, PriorityQueue<VectorDataOptics> orderSeeds)
        {
            var cDist = centerObject.CoreDistance;

            foreach (var obj in neighbors)
            {
                var op = obj.Data as VectorDataOptics;
                if (!op.Visited)
                {
                    var newRDistance = Math.Max(cDist, DistanceFunction
                            .CalculateDistance(op, centerObject));

                    if (double.IsPositiveInfinity(op.ReachabilityDistance))
                    {
                        op.ReachabilityDistance = newRDistance;
                        orderSeeds.Add(op);
                    }
                    else
                    {
                        if (newRDistance < op.ReachabilityDistance)
                        {
                            op.ReachabilityDistance = newRDistance;
                            orderSeeds.Remove(op);
                            orderSeeds.Add(op);
                        }
                    }
                }
            }
        }