📄 cluster.cs
字号:
using System;
namespace ClusterLibrary
{
/// <summary>
/// Summary description for Cluster.
/// </summary>
public class Cluster :System.Collections.ArrayList
{
// 努矾胶磐 ID甫 钎矫窍绰 Index
public int index;
/// <summary>
/// 货肺款 Cluster甫 积己茄促
/// </summary>
/// <param name="index"> 割 锅掳 Cluster牢瘤 钎矫窍绰 Index </param>
public Cluster(int index)
{
this.index = index;
}
public Cluster() {
}
/// <summary>
/// Cluster狼 Center甫 馆券茄促 (公霸 吝缴)
/// </summary>
/// <returns></returns>
public Point Center()
{
Point center = new Point();
if (this.Count == 0 ){
System.Console.WriteLine("Cluster狼 糕滚啊 绝嚼聪促.");
return center;
}
for ( int i = 0; i < this.Count ; i ++ ){
center = (Point)this[i] + center;
}
return ( center / this.Count );
}
/// <summary>
/// Cluster狼 Center阑 备窃 for J#
/// </summary>
/// <returns></returns>
public Point weight_center(){
return this.Center();
}
/// <summary>
/// Cluster狼 农扁甫 Return 窍绰 窃荐 for J#
/// Number of Points
/// </summary>
/// <returns></returns>
public int size(){
return this.Count;
}
/// <summary>
/// Cluster俊 甸绢乐绰 Point甫 波晨
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public Point GetPoint( int index ){
if ( index >= this.Count )
throw new Exception ( "Index out of range." );
return (ClusterLibrary.Point)this[index];
}
/// <summary>
/// Cluster俊 甸绢乐绰 Point甫 波晨 for J#
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public Point getValueAt( int index ){
return this.GetPoint(index);
}
public bool IsEmpty(){
return ( this.size() == 0 );
}
public void addValue( Point pt ){
this.Add(pt);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -