Пример #1
0
        public void AddPeak()
        {
            IMatrix <Arc> tmp;

            if (Oriented)
            {
                tmp = new SquareMatrix <Arc>(PeakCount + 1);
            }
            else
            {
                tmp = new TriangleMatrix <Arc>(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;
        }
Пример #2
0
        public void RemovePeak(int v) // !!!!
        {
            if ((uint)v > (uint)PeakCount)
            {
                throw new IndexOutOfRangeException("v");
            }

            IMatrix <Arc> tmp;

            if (Oriented)
            {
                tmp = new SquareMatrix <Arc>(PeakCount - 1);
            }
            else
            {
                tmp = new TriangleMatrix <Arc>(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;
        }