示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newOmega">omega.except thomthing</param>
        /// <param name="weights"> weight coef</param>
        /// <returns> Central Element</returns>
        public static CentralElement FindCentral(List <int> newOmega)
        {
            CentralElement centralElement = new CentralElement(-1, 0);

            foreach (WeightCoefficient _weight in Program.weights)
            {
                if (newOmega.Contains(_weight.index) && centralElement.weight < _weight.weight)
                {
                    centralElement.index  = _weight.index;
                    centralElement.weight = _weight.weight;
                }
            }

            return(centralElement);
        }
示例#2
0
 private static void FourthStepA()
 {
     quantityOfSecondPossibleExtension[indexOfSecondPlunk] = PossibleExtension.FindPossibleExtensions(secondOmega[indexOfSecondPlunk]);
     centralSecondElement[indexOfSecondPlunk].Add(CentralElement.FindCentral(secondOmega[indexOfSecondPlunk]));
     FourthStepA0();
 }
示例#3
0
        private static void SecondStepA1()
        {
            //формируем список F
            #region
            List <int> newMultitudeF = new List <int>();
            foreach (CentralElement element in supportingMultitudeF[indexOfFirstPlunk])
            {
                newMultitudeF.Add(element.index);
            }
            #endregion
            if (omega[indexOfFirstPlunk].Except(newMultitudeF).Count() == 0)
            {
                SecondStepA1b();
            }
            else
            {
                //формируем список F
                #region
                newMultitudeF = new List <int>();
                foreach (CentralElement element in supportingMultitudeF[indexOfFirstPlunk])
                {
                    newMultitudeF.Add(element.index);
                }
                #endregion
                centralElement = CentralElement.FindCentral(new List <int>(omega[indexOfFirstPlunk].Except(newMultitudeF)));
                if (IsEqual(quantityOfPossibleExtension[indexOfFirstPlunk], supportingMultitudeQ[indexOfFirstPlunk]))
                {
                    SecondStepA1c();
                }
                else if (new List <PossibleExtension>(quantityOfPossibleExtension[indexOfFirstPlunk].Except(supportingMultitudeQ[indexOfFirstPlunk])).Count != 0)
                {
                    knotElement = PossibleExtension.FindKnot(new List <PossibleExtension>(quantityOfPossibleExtension[indexOfFirstPlunk].Except(supportingMultitudeQ[indexOfFirstPlunk])));
                    //сравниваем веса претендентов на роль узлового и центрального эл-тов
                    if (knotElement.weight < centralElement.weight)//неравенство 2.3.1
                    {
                        SecondStepA1c();
                    }
                    else//неравенство 2.3.2
                    {
                        //левая часть
                        #region
                        int newWeight = 0;
                        for (int i = 0; i < supportingMultitudeQ.Count - 1; i++)//1 слагаемое
                        {
                            if (supportingMultitudeQ[i].Any())
                            {
                                foreach (WeightCoefficient weight in weights)
                                {
                                    if (supportingMultitudeQ[i].Last().i == weight.index || supportingMultitudeQ[i].Last().j == weight.index)
                                    {
                                        newWeight += weight.weight;
                                    }
                                }
                            }
                        }

                        /*foreach (List<PossibleExtension> element in supportingMultitudeQ)
                         * {
                         *  if (element.Any())
                         *  {
                         *      foreach (WeightCoefficient weight in weights)
                         *      {
                         *          if (element.Last().i == weight.index || element.Last().j == weight.index)
                         *          {
                         *              newWeight += weight.weight;//первое слагаемое
                         *          }
                         *      }
                         *  }
                         *
                         * }*/

                        newWeight += knotElement.weight;//сумма слагаемых
                        #endregion
                        if (newWeight > (firstRecord.weight + secondRecord.weight) / 2)
                        {
                            supportingMultitudeQ[indexOfFirstPlunk].Add(knotElement);
                            //формируем новое множество омега
                            List <int> usedIndexes = new List <int>();
                            usedIndexes.Add(knotElement.i);
                            usedIndexes.Add(knotElement.j);

                            omega.Add(new List <int>());
                            supportingMultitudeF.Add(new List <CentralElement>());
                            supportingMultitudeQ.Add(new List <PossibleExtension>());
                            quantityOfPossibleExtension.Add(new List <PossibleExtension>());
                            indexOfFirstPlunk++;

                            omega[indexOfFirstPlunk] = new List <int>(knotElement.elements.Except(usedIndexes));
                            SecondStep();
                        }
                        else
                        {
                            SecondStepA1b();
                        }
                    }
                }
            }
        }