private double Move_Vari_ValueCalculator(Element t0, Cluster sA)//should confirm AddVal[t0,s0]&AddVal[t0,sA] updated!! { Cluster s0 = getClusterbyID(t0.ClusterID); if (s0.ID == sA.ID) { return 0; } double NewFullValA = (Sum_Value[sA.ID] + AddVal[t0.ElementID, sA.ID]) / (sA.NumberLinks + sA.num); double NewFullVal0 = (Sum_Value[s0.ID] - AddVal[t0.ElementID, s0.ID]) / (s0.NumberLinks - s0.num + 1); double new_Vari_s0 = 0; Element ele1, ele2; double temval; #region MoveVariValue Changed in S0 ele1 = s0.First; while (ele1 != null) { if (ele1 != t0) { ele2 = ele1.After; while (ele2 != null) { if (ele2 != t0) { temval = CalculateScore(ele1, ele2); new_Vari_s0 += (temval - NewFullVal0) * (temval - NewFullVal0); } ele2 = ele2.After; } } ele1 = ele1.After; } #endregion #region MoveVariValue Changed in SA double new_Vari_SA = 0; ele1 = sA.First; while (ele1 != null) { ele2 = ele1.After; while (ele2 != null) { temval = CalculateScore(ele1, ele2); new_Vari_SA += (temval - NewFullValA) * (temval - NewFullValA); ele2 = ele2.After; } temval = CalculateScore(ele1, t0); new_Vari_SA += (temval - NewFullValA) * (temval - NewFullValA); ele1 = ele1.After; } #endregion new_Vari_s0 = new_Vari_s0 / (s0.NumberLinks - s0.num + 1); new_Vari_SA = new_Vari_SA / (sA.NumberLinks + sA.num); return new_Vari_s0 + new_Vari_SA - Vari_Value[s0.ID] - Vari_Value[sA.ID]; }
private double MoveValueCalculator(Element t0, Cluster sA) { double valueSA = Calculator(sA); double _valueSA = valueSA + AddValueCalculator(t0, sA); int numlinkSA = sA.num * (sA.num - 1) / 2; int _numlinkSA = numlinkSA + sA.num; double DelFullA = _valueSA / _numlinkSA - valueSA / numlinkSA; Cluster s0 = getClusterbyID(t0.ClusterID); double valueS0 = Calculator(s0); double _valueS0 = valueS0 - AddValueCalculator(t0, s0); int numlinkS0 = s0.num * (s0.num - 1) / 2; int _numlinkS0 = numlinkS0 - s0.num + 1; double DelFullD = _valueS0 / _numlinkS0 - valueS0 / numlinkS0; return DelFullA + DelFullD; }
private double AddValueCalculator(Element t0, Cluster s0) { Element t = s0.First; double tempval = 0; while (t != null) { tempval += CalculateScore(t0, t); t = t.After; } return tempval; }
private double VariValuesCalculator(Cluster c)//should confirm SumValue updated!! { double fullvalue = Sum_Value[c.ID]/c.NumberLinks; double varivalue = 0; Element ele1, ele2; ele1 = c.First; while (ele1 != null) { ele2 = ele1.After; while (ele2 != null) { double temval = CalculateScore(ele1, ele2); varivalue += (temval - fullvalue) * (temval - fullvalue); ele2 = ele2.After; } ele1 = ele1.After; } return varivalue / c.NumberLinks; }
private double FullvaluesCalculator(Cluster c) { double values = Calculator(c); double fullvalues = values / c.NumberLinks; return fullvalues; }
public double Calculator(Cluster c)//return Value of Cluster s { double temp = 0; Element em1 = c.First; Element em2; while (em1 != null) { em2 = em1.After; while (em2 != null) { temp += CalculateScore(em1, em2); em2 = em2.After; } em1 = em1.After; } return temp; }