Ejemplo n.º 1
0
        private GraphTuple[] IncrementArray(GraphTuple[] array)
        {
            GraphTuple[] holder = new GraphTuple[array.Length];

            array.CopyTo(holder, 0);

            array = new GraphTuple[array.Length + 10];

            holder.CopyTo(array, 0);

            return(array);
        }
Ejemplo n.º 2
0
        public void Add(int x, int y)
        {
            if (_counter == Plot.Length)
            {
                Plot = IncrementArray(Plot);
            }

            GraphTuple tuple = new GraphTuple();

            tuple.X = x;

            tuple.Y = y;

            Plot[_counter] = tuple;

            _counter++;
        }
Ejemplo n.º 3
0
        public GraphTuple[] GetLocalMin(int min, int max)
        {
            GraphTuple[] minTuple = new GraphTuple[5];

            int minTupleCounter = 0;

            for (int i = 0; i < _counter; i++)
            {
                GraphTuple tuple = Plot[i];

                if (tuple.X < min)
                {
                    continue;
                }

                if (tuple.X > max)
                {
                    break;
                }

                int x = Plot[i].X;

                int currentY = Plot[i].Y;

                int?previousY = null;

                int?nextY = null;

                if (minTuple.Length == minTupleCounter)
                {
                    minTuple = IncrementArray(minTuple);
                }

                if (i == 0)
                {
                    nextY = Plot[i + 1].Y;

                    if (nextY > currentY)
                    {
                        GraphTuple localMin = new GraphTuple();

                        tuple.X = x;

                        tuple.Y = currentY;

                        localMin.X = x;

                        localMin.Y = currentY;

                        minTuple[minTupleCounter] = localMin;

                        minTupleCounter++;
                    }
                }
                else if (i > 0 && i < _counter - 1)
                {
                    previousY = Plot[i - 1].Y;

                    nextY = Plot[i + 1].Y;

                    if (currentY < previousY && currentY < nextY)
                    {
                        GraphTuple localMin = new GraphTuple();

                        tuple.X = x;

                        tuple.Y = currentY;

                        localMin.X = x;

                        localMin.Y = currentY;

                        minTuple[minTupleCounter] = localMin;

                        minTupleCounter++;
                    }
                }
                else if (i > 0 && i == _counter - 1)
                {
                    previousY = Plot[i - 1].Y;

                    if (previousY > currentY)
                    {
                        GraphTuple localMin = new GraphTuple();

                        tuple.X = x;

                        tuple.Y = currentY;

                        localMin.X = x;

                        localMin.Y = currentY;

                        minTuple[minTupleCounter] = localMin;

                        minTupleCounter++;
                    }
                }
            }

            return(minTuple.Where(dd => dd != null).ToArray());
        }
Ejemplo n.º 4
0
        public Graph()
        {
            Plot = new GraphTuple[2];

            _counter = 0;
        }