예제 #1
0
        public void Cluster()
        {
            using (var status = StatusWrapper.NewStatus("DBScan", this.Data.Count))
            {
                //Console.WriteLine(this.RangeDiameter);
                this.RangeList = TimeCalculator
                                 .GetIndexRangeByTimeInterval(this.Data.Select(x => x.TimeTick).ToList(), RangeRadius);


                for (int i = 0; i < this.Data.Count; i++)
                {
                    if (this.Data[i].ClusterId > 0)
                    {
                        continue;
                    }

                    CurrentCluster = this.InnerClustering(i);

                    int t = 0;
                    while (t < this.CurrentCluster.Count)
                    {
                        var tl = this.InnerClustering(this.CurrentCluster[t++]);
                        if (tl.Any())
                        {
                            this.CurrentCluster.AddRange(tl);
                        }
                    }
                    status.PushProgress(this.CurrentCluster.Count);
                }
            }
            this.Validation();
        }
예제 #2
0
        private void BuildNeighbors()
        {
            using (var status = StatusWrapper.NewStatus("Building Neighbors", this.Data.Count))
            {
                var heap = new EasyHeapSmallFixedSize <NearestNeighbor>(HeapType.MinHeap, withTop, x => x.Distance);

                var rangeList = TimeCalculator.GetIndexRangeByTimeInterval(this.Data.Select(x => x.TimeTick).ToList(), Convert.ToInt64(kDisDiameter.TotalSeconds));

                for (int i = 0; i < this.Data.Count; i++)
                {
                    this.Data.GetRange(rangeList[i].Item1, rangeList[i].Item2 - rangeList[i].Item1)
                    .ForEach(x =>
                    {
                        var g = VectorPointHelper.GetDistance(this.Data[i], x, MathDistance);
                        if (g > 0)
                        {
                            heap.Push(new NearestNeighbor {
                                Distance = g, NeighborIndex = x.Id
                            });
                        }
                    });

                    this.Neighbors.Add(heap.GetList().ToList());
                    status.PushProgress();
                }
            }
        }