Example #1
0
        private static void ExpandCluster <XType, YType>(IDbscanPoint <XType, YType>[] points, IDbscanPoint <XType, YType> p, IDbscanPoint <XType, YType>[] neighbors, int cid, int eps, int minimumClusterCount)
        {
            p.ClusterId = cid;

            Queue <IDbscanPoint <XType, YType> > q = new Queue <IDbscanPoint <XType, YType> >(neighbors);

            while (q.Count > 0)
            {
                IDbscanPoint <XType, YType> n = q.Dequeue();
                if (!n.IsVisited)
                {
                    n.IsVisited = true;

                    IDbscanPoint <XType, YType>[] ns = DbscanAlgorithm.GetNeighors(points, n, eps);
                    if (ns.Length >= minimumClusterCount)
                    {
                        foreach (IDbscanPoint <XType, YType> item in ns)
                        {
                            q.Enqueue(item);
                        }
                    }
                }
                else if (!n.ClusterId.HasValue)
                {
                    n.ClusterId = cid;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Determines whether the specified point neighbors the current instance using the specified value.
        /// </summary>
        /// <param name="point">The point to test as a neighor.</param>
        /// <param name="eps">The value to use to find neighoring points.</param>
        /// <returns>True if the point is a neighbor; otherwise, false.</returns>
        public bool IsNeighbor(IDbscanPoint <int, int> point, double eps)
        {
            int dis = TaskBitmap.DistanceBetween(new Point(point.X, point.Y), new Point(this.X, this.Y));

            return(dis < eps);
        }
Example #3
0
        private static IDbscanPoint <XType, YType>[] GetNeighors <XType, YType>(IDbscanPoint <XType, YType>[] points, IDbscanPoint <XType, YType> point, int eps)
        {
            List <IDbscanPoint <XType, YType> > neighbors = new List <IDbscanPoint <XType, YType> >();

            neighbors.Add(point);

            foreach (IDbscanPoint <XType, YType> p in points)
            {
                if (point.IsNeighbor(p, eps))
                {
                    neighbors.Add(p);
                }
            }

            return(neighbors.ToArray());
        }