Exemple #1
0
        static BinaryString[] GetCentroids(List <List <DBSCANElement> > clusterDetails)
        {
            BinaryString[] centroids = new BinaryString[clusterDetails.Count];
            for (int i = 0; i < clusterDetails.Count; i++)
            {
                BinaryString centroid = clusterDetails[i][0].Value;
                double       cost     = double.MaxValue;
                for (int j = 0; j < clusterDetails[i].Count; j++)
                {
                    double tempCost = 0;
                    for (int k = 0; k < clusterDetails[i].Count; k++)
                    {
                        if (j != k)
                        {
                            tempCost += MatchingMachine.GetHammingDis(clusterDetails[i][j].Value, clusterDetails[i][k].Value);
                        }
                    }

                    if (tempCost < cost)
                    {
                        centroid = clusterDetails[i][j].Value;
                        cost     = tempCost;
                    }
                }
                centroids[i] = centroid;
            }
            return(centroids);
        }
Exemple #2
0
 public static int Distance(DBSCANElement p1, DBSCANElement p2)
 {
     return(MatchingMachine.GetHammingDis(p1.Value, p2.Value));
 }