当前位置: 首页>>代码示例>>C#>>正文


C# Cluster.Add方法代码示例

本文整理汇总了C#中Cluster.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Cluster.Add方法的具体用法?C# Cluster.Add怎么用?C# Cluster.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cluster的用法示例。


在下文中一共展示了Cluster.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExpandCluster

 private void ExpandCluster(Point p, Cluster c, List<Point> neighbors)
 {
     c.Add(p);
     p.inCluster = true;
     //			foreach (Point neighbor in neighbors)
     for  (int i=0; i<neighbors.Count; ++i)
     {
         Point neighbor = neighbors[i];
         if (neighbor.Processed == false)
         {
             neighbor.Processed = true;
             var newNeighbors = db.Neighbors(neighbor, Epsilon);
             if (newNeighbors.Count >= MinPts)
             {
                 neighbors = neighbors.Union(newNeighbors).ToList();
             }
         }
         if (neighbor.inCluster == false)
         {
             c.Add(neighbor);
             neighbor.inCluster = true;
         }
     }
 }
开发者ID:JeongMinCha,项目名称:Clustering,代码行数:24,代码来源:DBSCAN.cs

示例2: Clustering

        public void Clustering(string inputFile, int clusterNum)
        {
            int clusterIndex = 0;
            var clusterOf = new int[db.Count()];		// cluster indexes of points
            int curCluster = db.Count();

            foreach (var pair in db.DistanceSortedList())
            {
                int p1 = pair.Key.id1;
                int p2 = pair.Key.id2;
                if (curCluster == clusterNum + 2)
                    break;

                // If clusterOf[p1] == 0, p1 is not included into any cluster.
                if (clusterOf[p1] == 0 && clusterOf[p2] == 0)
                {
                    ++ clusterIndex;
                    clusterOf[p1] = clusterIndex;
                    clusterOf[p2] = clusterIndex;
                }
                else if (clusterOf[p1] != 0 && clusterOf[p2] == 0)
                {
                    clusterOf[p2] = clusterOf[p1];
                }
                else if (clusterOf[p1] == 0 && clusterOf[p2] != 0)
                {
                    clusterOf[p1] = clusterOf[p2];
                }
                else if (clusterOf[p1] != 0 && clusterOf[p2] != 0)
                {
                    int clusterIndex1 = clusterOf[p1];
                    int clusterIndex2 = clusterOf[p2];

                    if (clusterIndex1 == clusterIndex2) {
                        // no change
                        continue;
                    }

                    int minIndex = (clusterIndex1 < clusterIndex2) ? clusterIndex1 : clusterIndex2;
                    int maxIndex = (clusterIndex1 > clusterIndex2) ? clusterIndex1 : clusterIndex2;

                    for (int i=0; i<clusterOf.Length; ++i)
                    {
                        if (clusterOf[i] == maxIndex)
                        {
                            clusterOf[i] = minIndex;
                        }
                    }
                }
                -- curCluster;
            }

            HashSet<int> hSet = new HashSet<int>();
            foreach (int idx in clusterOf)
            {
                hSet.Add(idx);
            }

            clusterList = new List<Cluster>();
            foreach (int clustIdx in hSet)
            {
                Cluster cluster = new Cluster();
                for (int i=0; i<clusterOf.Length; ++i)
                {
                    if (clusterOf[i] == clustIdx)
                    {
                        cluster.Add(db[i]);
                    }
                }
                clusterList.Add(cluster);
            }

            WriteOutput(inputFile);
        }
开发者ID:JeongMinCha,项目名称:Clustering,代码行数:74,代码来源:AGNES.cs

示例3: AssignRandomSeeds

        private List<Point> AssignRandomSeeds(int clusterNum)
        {
            clusterList = new List<Cluster>();
            var randomSeeds = RandomPoints(clusterNum);
            for(int i=0; i<clusterNum; ++i)
            {
                Point seed = randomSeeds[i];
                seed.inCluster = true;
                seed.isSeed = true;
                seed.clusterIdx = i;

                Cluster cluster = new Cluster();
                cluster.Add(seed);
                clusterList.Add(cluster);
            }

            return randomSeeds;
        }
开发者ID:JeongMinCha,项目名称:Clustering,代码行数:18,代码来源:PAM.cs


注:本文中的Cluster.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。