dbscan_聚类分析_图形界面


 最近用C#做的一个DBSCAN的聚类算法.有图形界面.

  加多了个凹包..

  还可以单步运行.查看效果..



dbscan_聚类分析_图形界面_第1张图片

代码写的不怎样.还请海涵!!

具体就看下代码吧.很容易懂.就不解释了

主要代码段如下.

可以查看维基百科算法介绍

 :http://en.wikipedia.org/wiki/DBSCAN

一段伪代码:

DBSCAN(D, eps, MinPts)
   C = 0
   for each unvisited point P in dataset D
      mark P as visited
      NeighborPts = regionQuery(P, eps)
      if sizeof(NeighborPts) < MinPts
         mark P as NOISE
      else
         C = next cluster
         expandCluster(P, NeighborPts, C, eps, MinPts)
          
expandCluster(P, NeighborPts, C, eps, MinPts)
   add P to cluster C
   for each point P' in NeighborPts 
      if P' is not visited
         mark P' as visited
         NeighborPts' = regionQuery(P', eps)
         if sizeof(NeighborPts') >= MinPts
            NeighborPts = NeighborPts joined with NeighborPts'
      if P' is not yet member of any cluster
         add P' to cluster C
          
regionQuery(P, eps)
   return all points within P's eps-neighborhood (including P)

程序中的实际部分

      public int  DBSCAN_Cluster()
        {
            clustet_set=new ArrayList();
            Cluster_temp_arrayList = new ArrayList();
             
            Initial_Cluster_TableList();
            DataPoint dp;
            int n=0;
             
            for (int i = 0; i < DataPoints_arry.Count; i++ ,n++)//对应课本P128的第2行--
            {
                dp = (DataPoint)DataPoints_arry[i];
                if (dp.used_tag || dp.corePoint_tag)//第三行
                    continue;
                else
                {
                    if (!isCorePoint(i))
                        dp.corePoint_tag = false;
                    else
                    {
                        dp.corePoint_tag = true;
                        //Console.WriteLine("corePoint");
                        dp.cluster_tag = current_cluster_id;
                        dp.used_tag = true;
                        CorePointCluster(i, current_cluster_id  ,ref n ,ref Cluster_temp_arrayList);
                        //完成Nesp(p)归入族,同时对族中点进行多一遍计算的任务.
                        current_cluster_id++;
                        clustet_set.Add(Cluster_temp_arrayList);
                        Console.WriteLine(" n=" +Cluster_temp_arrayList.Count);
                        Cluster_temp_arrayList = new ArrayList();
                    }
                }
            }
            return n;
        }


 下载地址:http://download.csdn.net/detail/f112122/7482303





你可能感兴趣的:(dbscan_聚类分析_图形界面)