Esempio n. 1
0
 public void Add(Claster cl)
 {
     _list.Add(cl);
 }
Esempio n. 2
0
        public static List <Claster> Conection_Method(double[][] mass, int size, int type, double eps)
        {
            int[]     clast = new int[size];
            bool[]    used  = new bool[size];
            Claster[] clist = new Claster[size];
            for (int i = 0; i < size; ++i)
            {
                clast[i] = i;
                clist[i] = new Claster(i);
            }
            List <int> pair = new List <int>();
            int        k    = 0;
            int        f    = 0;
            List <int> tmp  = new List <int>();

            while (f < size)
            {
                if (type == 0)
                {
                    pair = Single(mass, clast, size);
                }
                else if (type == 1)
                {
                    pair = Full(mass, clast, size, eps);
                }
                // f += pair.Count;
                if (pair.Count != 0)
                {
                    k = min(pair);
                    Claster cl = new Claster(-1 * (k + 1));
                    foreach (int e in pair)
                    {
                        if (!used[e])
                        {
                            used[e] = true; f++;
                        }
                        cl.Add(clist[e]);
                        tmp = hasCommon(e, clast);
                        foreach (int el in tmp)
                        {
                            clist[el] = cl;
                            clast[el] = k;
                        }
                    }
                }
                else
                {
                    f++;
                }
            }
            tmp.Clear();
            List <Claster> claster = new List <Claster>();

            for (int i = 0; i < size; ++i)
            {
                if (!tmp.Contains(clast[i]))
                {
                    tmp.Add(clast[i]);
                    claster.Add(clist[i]);
                }
            }

            return(claster);
        }