Results 1 to 1 of 1
  1. #1

    Thread Starter
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009

    Density-Based Spatial Clustering of Applications with Noise (DBSCAN)

    Quote Originally Posted by wikipedia
    Density-based spatial clustering of applications with noise (DBSCAN) is a data clustering algorithm. It is a density-based clustering algorithm because it finds a number of clusters starting from the estimated density distribution of corresponding nodes. DBSCAN is one of the most common clustering algorithms.

    How to use:

    1. Add Dbscan.cs to your project.
    2. Add Dbscan.txt to your project, set the Copy to Output Directory property to Copy always on it.
    3. Add a chart (from the System.Windows.Forms.DataVisualization namespace) to the form.
    4. Add the code below to your form. (VB Version Here)

    public partial class Form1 : Form
        #region fields
        private static Color[] ChartColors = new Color[] { Color.FromArgb(0x41, 140, 240),   Color.FromArgb(0xfc, 180, 0x41),  
                                                           Color.FromArgb(0xe0, 0x40, 10),   Color.FromArgb(5, 100, 0x92), 
                                                           Color.FromArgb(0xbf, 0xbf, 0xbf), Color.FromArgb(0x1a, 0x3b, 0x69), 
                                                           Color.FromArgb(0xff, 0xe3, 130),  Color.FromArgb(0x12, 0x9c, 0xdd), 
                                                           Color.FromArgb(0xca, 0x6b, 0x4b), Color.FromArgb(0, 0x5c, 0xdb),    
                                                           Color.FromArgb(0xf3, 210, 0x88),  Color.FromArgb(80, 0x63, 0x81), 
                                                           Color.FromArgb(0xf1, 0xb9, 0xa8), Color.FromArgb(0xe0, 0x83, 10),   
                                                           Color.FromArgb(120, 0x93, 190) };
        #region constructors
        public Form1()
        #region methods
        private void InitializeChart()
            Series series = this.chart1.Series[0];
            series.ChartType = SeriesChartType.Point;
            series.MarkerStyle = MarkerStyle.Circle;
            series.MarkerSize = 10;
            this.chart1.Legends[0].Enabled = false;
            this.chart1.ChartAreas[0].AxisX.LabelStyle.Format = "N3";
            this.chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
            this.chart1.ChartAreas[0].AxisY.LabelStyle.Format = "N3";
            this.chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
        protected override void OnLoad(EventArgs e)
            // generate chart based on Dbscan.txt
        private void GenerateClusters()
            List<DbscanPoint> points = new List<DbscanPoint>();
            // change path as appropriate
            var lines = System.IO.File.ReadAllLines("Dbscan.txt");
            foreach (var line in lines)
                var split = line.Split(' ');
                points.Add(new DbscanPoint(Convert.ToDouble(split[1]), 
            // customize the epsilion radius and minimum cluster points here
            // note: if you are using http://people.cs.nctu.edu.tw/~rsliang/dbscan/testdatagen.html
            //       to generate data, make sure these parameters match the parameters on the site
            //       otherwise you will get different results
            DbscanAlgorithm.Dbscan(points.ToArray(), 4d, 6);
            var series = this.chart1.Series[0];
            foreach (var item in points)
                var p = series.Points[series.Points.AddXY(item.X, item.Y)];
                if (item.IsNoise)
                    p.Color = SystemColors.Control;
                    p.Color = Form1.ChartColors[(item.ClusterId.Value - 1) % Form1.ChartColors.Length];
    You should see this if everything was successful:

    Name:  Dbscan.png
Views: 2428
Size:  27.9 KB

    Here's how you can generate test data (this is what I verified the algorithm against): http://people.cs.nctu.edu.tw/~rslian...stdatagen.html.
    Attached Files Attached Files
    Last edited by ForumAccount; Feb 20th, 2014 at 07:06 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width