示例#1
0
        public void SetPreviousGiver(string giver, string recipient)
        {
            int giverIndex     = _thawedMatrix.GetIndex(giver);
            int recipientIndex = _thawedMatrix.GetIndex(recipient);
            int prevWeight     = _thawedMatrix.GetWeight(giverIndex, recipientIndex);

            _thawedMatrix.SetWeight(giverIndex, recipientIndex, prevWeight + 1);
        }
        private static int Cost(int[,] next, GiftMatrix thawedMatrix)
        {
            int partialCost = 0;

            for (int i = 0; i < thawedMatrix.NumberOfParticipants; i++)
            {
                for (int j = 0; j < thawedMatrix.NumberOfParticipants; j++)
                {
                    partialCost += next[i, j] * thawedMatrix.GetWeight(i, j);
                }
            }

            return(partialCost);
        }