Пример #1
0
        /*
         * Построение правой (верхней) стороны входной матрицы.
         */
        public static float[][] GetRightTopPartOfInputMatrix(float[][] generatedOutputMatrix,
                                                             float[][] generatedInputMatrix)
        {
            for (int person = 0; person < generatedOutputMatrix.GetLength(0); person++)
            {
                generatedInputMatrix[person] = new float[generatedOutputMatrix.GetLength(0)];

                for (int relative = person; relative < generatedOutputMatrix.GetLength(0); relative++)
                {
                    for (int relationship = 0; relationship < RelationshipsMatrix.GetLength(1); relationship++)
                    {
                        if (RelationshipsMatrix[NumberOfProband, relationship][0] ==
                            generatedOutputMatrix[person][relative])
                        {
                            generatedInputMatrix[person][relative] =
                                GetCmEquivalentOfRelationshipType(generatedInputMatrix, person, relative,
                                                                  relationship);
                        }

                        if (RelationshipsMatrix[relationship, NumberOfProband][0] ==
                            generatedOutputMatrix[person][relative])
                        {
                            generatedInputMatrix[person][relative] =
                                GetCmEquivalentOfRelationshipType(generatedInputMatrix, person, relative,
                                                                  relationship);
                        }
                    }
                }
            }

            return(generatedInputMatrix);
        }
Пример #2
0
        /*
         * Построение списка возможных степеней родства пробанда.
         */
        public static List <int> GetListOfAllPossibleRelationshipsOfProband(List <int> existingRelationshipDegrees)
        {
            existingRelationshipDegrees = existingRelationshipDegrees.Where(var => var != 1).ToList();

            List <int> allPossibleRelationshipsOfProband = new List <int>();

            for (int i = 1; i < RelationshipsMatrix.GetLength(0); i++)
            {
                int numberOfPossibleRelationships = 0;

                for (int j = 1; j < RelationshipsMatrix.GetLength(1); j++)
                {
                    for (int k = 0; k < RelationshipsMatrix[i, j].Length; k++)
                    {
                        if (existingRelationshipDegrees.Contains(RelationshipsMatrix[i, j][k]))
                        {
                            numberOfPossibleRelationships++;
                            break;
                        }
                    }
                }

                if (numberOfPossibleRelationships > 0.5 * existingRelationshipDegrees.Count)
                {
                    allPossibleRelationshipsOfProband.Add(RelationshipsMatrix[NumberOfProband, i][0]);
                }
            }

            return(allPossibleRelationshipsOfProband);
        }
Пример #3
0
        /*
         * Нахождение всех существующих степеней родства.
         */
        public static List <int> GetAllExistingRelationshipDegrees()
        {
            List <int> existingRelationshipDegrees = new List <int>();

            existingRelationshipDegrees.AddRange((from i in Enumerable.Range(0, RelationshipsMatrix.GetLength(0))
                                                  select RelationshipsMatrix[NumberOfProband, i][0]).ToList());

            return(existingRelationshipDegrees.Distinct().ToList());
        }
Пример #4
0
        /*
         * Среди возможных видов родства пробанда ищутся порядковые номера тех, что содержат выбранные виды родства.
         */
        public static int GetSerialNumberInListOfPossibleRelationships(float[][] generatedOutputMatrix, List <int> persons,
                                                                       List <int> relatives, int relative,
                                                                       int previousPerson)
        {
            int numberOfJ = -1;

            try
            {
                numberOfJ =
                    (from number in Enumerable.Range(0, RelationshipsMatrix.GetLength(1))
                     where RelationshipsMatrix[NumberOfProband, number][0] ==
                     generatedOutputMatrix[persons[previousPerson]][relatives[relative]]
                     select number).Single();
            }
            catch (InvalidOperationException IOE)
            {
                Console.WriteLine(IOE);
            }

            return(numberOfJ);
        }
Пример #5
0
        /*
         * Построение левой (нижней) стороны выходной матрицы.
         */
        public static float[][] GetLeftBottomPartOfOutputMatrix(float[][] generatedOutputMatrix)
        {
            for (int genPerson = 1; genPerson < generatedOutputMatrix.GetLength(0); genPerson++)
            {
                for (int genRelative = 0; genRelative < genPerson; genRelative++)
                {
                    try
                    {
                        generatedOutputMatrix[genPerson][genRelative] =
                            (from genRelationship in Enumerable.Range(0, RelationshipsMatrix.GetLength(1))
                             where RelationshipsMatrix[NumberOfProband, genRelationship][0] ==
                             generatedOutputMatrix[genRelative][genPerson]
                             select RelationshipsMatrix[genRelationship, NumberOfProband][0]).Single();
                    }
                    catch (InvalidOperationException IOE)
                    {
                        Console.WriteLine(IOE);
                    }
                }
            }

            return(generatedOutputMatrix);
        }