public object Clone() { WeightsMatrix sm = new WeightsMatrix(Size); for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { sm.SetWeight(i, j, GetWeight(i, j)); } } return(sm); }
public SortResult Sort() { SortResult vector = new SortResult(_element.Children.Count); if (_element.Children.Count > 1) { WeightsMatrix matrix = BuildPartitionMatrix(_element.Children); PartitioningCalculation algorithm = new PartitioningCalculation(matrix); vector = algorithm.Partition(); } return(vector); }
private WeightsMatrix BuildPartitionMatrix(IList <IDsmElement> nodes) { WeightsMatrix matrix = new WeightsMatrix(nodes.Count); for (int i = 0; i < nodes.Count; i++) { IDsmElement provider = nodes[i]; for (int j = 0; j < nodes.Count; j++) { if (j != i) { IDsmElement consumer = nodes[j]; int weight = _model.GetDependencyWeight(consumer.Id, provider.Id); matrix.SetWeight(i, j, weight > 0 ? 1 : 0); } } } return(matrix); }
/// <summary> /// Constructor of calcualtion on a given n * n matrix /// </summary> /// <param name="matrix"></param> public PartitioningCalculation(WeightsMatrix matrix) { _sm = matrix; }