private int LMinimalDist(List <HClusterNode> levelNodes)
        {
            int min = Int32.MaxValue;

            for (int i = 0; i < levelNodes.Count; i++)
            {
                HClusterNode refStruct = levelNodes[i];
                for (int j = i + 1; j < levelNodes.Count; j++)
                {
                    int dist = dMeasure.FindMinimalDistance(refStruct, levelNodes[j], linkageType).Key;
                    if (min > dist)
                    {
                        min = dist;
                    }
                }
            }
            return(min);
        }
示例#2
0
        private List <List <HClusterNode> > LevelMinimalDist(List <HClusterNode> levelNodes)
        {
            List <List <HClusterNode> > res = new List <List <HClusterNode> >();

            min = Int32.MaxValue;

            for (int i = 0; i < levelNodes.Count; i++)
            {
                // if (levelNodes[i].fNode)
                //    continue;
                List <HClusterNode> lista = new List <HClusterNode>();
                lista.Add(levelNodes[i]);
                for (int j = i + 1; j < levelNodes.Count; j++)
                {
                    //if (levelNodes[j].fNode)
                    //    continue;
                    int dist = dMeasure.FindMinimalDistance(levelNodes[i], levelNodes[j], linkageType);
                    if (min > dist)
                    {
                        min = dist;
                        foreach (var item in lista)
                        {
                            item.fNode = false;
                        }
                        lista.Clear();
                        foreach (var item in res)
                        {
                            foreach (var it in item)
                            {
                                it.fNode = false;
                            }
                        }
                        res.Clear();

                        lista.Add(levelNodes[i]);
                        lista.Add(levelNodes[j]);
                        levelNodes[i].fNode = true;
                        levelNodes[j].fNode = true;
                    }
                    else
                    if (min == dist)
                    {
                        if (!levelNodes[j].fNode && !levelNodes[i].fNode)
                        {
                            lista.Add(levelNodes[j]);
                            levelNodes[j].fNode = true;
                        }
                    }
                }
                if (lista.Count >= 2)
                {
                    res.Add(lista);
                }
            }

            foreach (var item in res)
            {
                foreach (var it in item)
                {
                    it.fNode = true;
                }
            }

            return(res);
        }