예제 #1
0
        public void AddPeak()
        {
            IMatrix <bool> tmp;

            if (Oriented)
            {
                tmp = new BitsSquareMatrix(PeakCount + 1);
            }
            else
            {
                tmp = new BitsTriangleMatrix(PeakCount + 1);
            }

            if (Oriented)
            {
                for (int i = 0; i < PeakCount; i++)
                {
                    for (int j = 0; j < PeakCount; j++)
                    {
                        if (i != j)
                        {
                            tmp[i, j] = matrix[i, j];
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < PeakCount - 1; i++)
                {
                    for (int j = i + 1; j < PeakCount; j++)
                    {
                        tmp[i, j] = matrix[i, j];
                    }
                }
            }

            matrix = tmp;
            Array.Resize(ref inArcsCount, matrix.Length);
        }
예제 #2
0
        public void RemovePeak(int v) //// !!!!!!!!!!!!!!!!!!!!! Походу невозможно, либо неадекватно
        {
            if ((uint)v > (uint)PeakCount)
            {
                throw new IndexOutOfRangeException("v");
            }

            IMatrix <bool> tmp;

            if (Oriented)
            {
                tmp = new BitsSquareMatrix(PeakCount - 1);             // нужны битовые матрицы
            }
            else
            {
                tmp = new BitsTriangleMatrix(PeakCount - 1);
            }

            if (Oriented)
            {
                for (int i = 0; i < v; i++)
                {
                    for (int j = 0; j < v; j++)
                    {
                        if (i != j)
                        {
                            tmp[i, j] = matrix[i, j];
                        }
                    }

                    for (int j = v + 1; j < PeakCount; j++)
                    {
                        if (i != j - 1)
                        {
                            tmp[i, j - 1] = matrix[i, j];
                        }
                    }
                }

                for (int i = v + 1; i < PeakCount; i++)
                {
                    for (int j = 0; j < v; j++)
                    {
                        if (i - 1 != j)
                        {
                            tmp[i - 1, j] = matrix[i, j];
                        }
                    }

                    for (int j = v + 1; j < PeakCount; j++)
                    {
                        if (i != j)
                        {
                            tmp[i - 1, j - 1] = matrix[i, j];
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < v; i++)
                {
                    for (int j = i + 1; j < v; j++)
                    {
                        tmp[i, j] = matrix[i, j];
                    }

                    for (int j = v + 1; j < PeakCount; j++)
                    {
                        tmp[i, j - 1] = matrix[i, j];
                    }
                }

                for (int i = v + 1; i < PeakCount; i++)
                {
                    for (int j = i + 1; j < v; j++)
                    {
                        tmp[i - 1, j] = matrix[i, j];
                    }

                    for (int j = v + 1; j < PeakCount; j++)
                    {
                        tmp[i - 1, j - 1] = matrix[i, j];
                    }
                }
            }

            matrix = tmp;

            inArcsCount = new int[matrix.Length];

            for (int i = 0; i < matrix.Length; i++)   /// !!!!!!!!!!!!
            {
                for (int j = 0; j < matrix.Length; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    if (matrix[i, j])
                    {
                        inArcsCount[j]++;
                    }
                }
            }
        }