Example #1
0
        private /*MatrixСмежная[][]*/ MatЗаполнитель getMatЗаполнитель(/*MatrixСмежная[][]*/ MatЗаполнитель mat, /*int rows, int column, int h, */ Node_struct nod, bool izvest)
        {
            if (mat.column == 0)
            {
                Console.WriteLine("Заполнитель уперся в нулевой столбец");
                return(mat);
            }
            Console.WriteLine("Заполнитель id nod - " + nod.ID);
            Node nodes = new Node();

            MatrixСмежная[][] matrix = mat.matrix;
            int rows = mat.rows, column = mat.column, h = mat.h;

            for (int i = 0, hw = 0, hv = 0, j = 0; i < rows; i++)
            {
retigoto:
                if (hw < h)
                {
                    matrix[i][column - 1].nod      = nod;
                    matrix[i][column - 1].property = nod.props[j];
                    matrix[i][column - 1].value    = nod.props[j].values[hv];
                    hw++;
                }
                else
                {
                    j++;
                    if (j >= nod.props.Count)
                    {
                        j = 0; hv++;
                        if (hv >= nod.props[j].values.Count)
                        {
                            hv = 0;
                        }
                    }
                    hw = 0;
                    goto retigoto;
                }
            }
            if (h == 1)
            {
                h = nod.props.Count;
            }
            else
            {
                h *= nod.props.Count;
            }
            mat.matrix = matrix;
            mat.rows   = rows;
            mat.column = column - 1;
            mat.h      = h;
            if (izvest)
            {
                return(mat);
            }
            List <Node_struct> incon = new List <Node_struct>();

            foreach (var nodf in nod.connects_in)
            {
                if (!nodes.getEstProperyTrueFix(nodf.props))
                {
                    mat = getMatЗаполнитель(mat, nodf, false);
                }
                else
                {
                    mat = getMatЗаполнитель(mat, nodf, true);
                }
            }
            return(mat);
        }
Example #2
0
        private List <Node_struct> MathДетейПоИзвестномуРодителю(Node_struct nod, List <Node_struct> list)
        {
metkaошибказаполнителя:
            int rows = -1, column = -1;

            rows   = getMatСмежКолСтрок(nod, false);
            column = getMatCмежКолСтолбцов(nod, false);
            if (rows == -1 || column == -1)
            {
                Console.WriteLine("-------------------------------------------");
                Console.WriteLine("Ошибка в вычислениях вверх метод - по известному родителю");
                Console.WriteLine("-------------------------------------------");
                return(list);
            }
            else
            {
                Console.WriteLine("Math up info: rows - " + rows + ", column -" + column);
            }
            Node classnode = new Node();

            MatrixСмежная[][] matrix = new MatrixСмежная[rows][];
            Parallel.For(0, rows, (i, state) =>
            {
                matrix[i] = new MatrixСмежная[column];
                for (int j = 0; j < column; j++)
                {
                    matrix[i][j] = new MatrixСмежная();
                }
            });
            MatЗаполнитель mat = new MatЗаполнитель();

            mat.matrix = matrix;
            mat.rows   = rows;
            mat.column = column;
            mat.h      = 1;
            bool ошибказаполнителя = false;

            matrix = getMatЗаполнитель(mat /*, rows, column, 1*/, nod, false).matrix;
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < column - 1; j++)
                {
                    try
                    {
                        if (classnode.getEstProperyTrueFix(matrix[i][j].nod.props) == false)
                        {
                            matrix[i][j].property.value_editor = 0;
                        }
                        else if (matrix[i][j].property.proc100)
                        {
                            matrix[i][j].value = 1;
                        }
                        else
                        {
                            matrix[i][j].value = 0;
                        }
                    }
                    catch (System.NullReferenceException ex)
                    {
                        Console.WriteLine("Ошибка заполнителя matirx[" + i + "][" + j + "]" + ex.ToString());
                        ошибказаполнителя = true;
                        break;
                    }
                }
            }

            if (ошибказаполнителя)
            {
                goto metkaошибказаполнителя;
            }
            double[] massres = new double[rows];
            double[,] mati = new double[rows, column - 1];
            for (int i = 0; i < rows; i++)
            {
                double proiz = matrix[i][column - 1].value;
                for (int j = 0; j < column - 1; j++)
                {
                    if (matrix[i][j].nod != null)
                    {
                        proiz *= matrix[i][j].value;
                    }
                }
                massres[i] = proiz;
            }
            печатьИнформации(rows, column, matrix, nod, massres);
            for (int j = 0; j < column /* - 1*/; j++)
            {
                for (int i = 0; i < rows; i++)
                {
                    if (matrix[i][column - 1].property.proc100)
                    {
                        matrix[i][j].property.value_editor += massres[i] / matrix[i][column - 1].property.value_editor_down;
                    }
                }
            }
            return(list);
        }