public override double CalculateDistance(Structuring structA, Structuring structB, Set dataSet) { bool[,] adjMatrix = new bool[dataSet.ElementsCount, dataSet.ElementsCount]; int[] visited = new int[dataSet.ElementsCount]; int ccCount = 0; for (int i = 0; i < dataSet.ElementsCount - 1; i++) { for (int j = i + 1; j < dataSet.ElementsCount; j++) { if (structA.BeSameCluster(dataSet[i], dataSet[j]) || structB.BeSameCluster(dataSet[i], dataSet[j])) { adjMatrix[i, j] = adjMatrix[j, i] = true; } } } for (int i = 0; i < dataSet.ElementsCount; i++) { if (visited[i] == 0) { ccCount++; DFS(i, adjMatrix, visited, ccCount); } } return(2 * (dataSet.ElementsCount - ccCount) - (dataSet.ElementsCount - structA.ClustersCount) - (dataSet.ElementsCount - structB.ClustersCount)); }
public override double EvaluatePartition() { FillHeaps(); double minInter = double.MaxValue; double maxIntra = double.MinValue; for (int i = 0; i < Set.ElementsCount; i++) { while (lh[i].First != null) { double distance = lh[i].First.Rank; if (distance < minInter && !Structuring.BeSameCluster(Set.Elements[i], Set.Elements[lh[i].First.Cluster])) { minInter = distance; } else if (distance > maxIntra && Structuring.BeSameCluster(Set.Elements[i], Set.Elements[lh[i].First.Cluster])) { maxIntra = distance; } lh[i].RemoveFirst(); } } return(minInter / maxIntra); }
public override double EvaluatePartition() { FillHeaps(); double result = 0; for (int i = 0; i < Set.ElementsCount; i++) { int cont = 0; while (lh[i].First != null) { if (cont == Neighbors) { break; } double distance = lh[i].First.Rank; if (!Structuring.BeSameCluster(Set.Elements[i], Set.Elements[lh[i].First.Cluster])) { result += 1 / distance; } lh[i].RemoveFirst(); cont++; } } return(result); }
public override double CalculateDistance(Structuring structA, Structuring structB, Set Set) { int _FP = 0, _FN = 0; for (int i = 0; i < Set.ElementsCount; i++) { for (int j = i + 1; j < Set.ElementsCount; j++) { bool sameClusterA = structA.BeSameCluster(Set[i], Set[j]); bool sameClusterB = structB.BeSameCluster(Set[i], Set[j]); if (!sameClusterA && sameClusterB) { _FP++; } if (sameClusterA && !sameClusterB) { _FN++; } } } return(_FN + _FP); }