private State DeleteEdges(State state, int row, int col)
        {
            state.GetCityTo()[row]   = col;
            state.GetCityFrom()[col] = row;
            state.SetCitiesInSolution(state.GetCitiesInSolution() + 1);

            if (state.GetCitiesInSolution() < _cities.Length - 1)
            {
                int start = row;
                int end   = col;

                while (state.GetCityFrom()[start] != -1)
                {
                    start = state.GetCityFrom()[start];
                }

                while (state.GetCityTo()[end] != -1)
                {
                    end = state.GetCityTo()[end];
                }

                while (start != col)
                {
                    state.Matrix.GetMatrix()[end, start] = double.PositiveInfinity;
                    state.Matrix.GetMatrix()[col, start] = double.PositiveInfinity;

                    start = state.GetCityTo()[start];
                }
            }

            return(state);
        }
        private State GenerateReducedMatrix(State state)
        {
            Matrix matrix = state.Matrix;

            // This is the total cost of reduction.
            double sumDifference = 0;

            // Reduce row by row
            for (int i = 0; i < matrix.GetMatrix().GetLength(0); i++)
            {
                // Only reduce the row if a cell in this row has NOT already been select as part of the path.
                if (state.GetCityTo()[i] == -1)
                {
                    double rowMin = double.PositiveInfinity;

                    for (int j = 0; j < matrix.GetMatrix().GetLength(0); j++)
                    {
                        if (matrix.GetMatrix()[i, j] < rowMin)
                        {
                            rowMin = matrix.GetMatrix()[i, j];
                        }
                    }

                    if (!double.IsInfinity(rowMin))
                    {
                        for (int j = 0; j < matrix.GetMatrix().GetLength(0); j++)
                        {
                            matrix.GetMatrix()[i, j] -= rowMin;
                        }
                    }

                    sumDifference += rowMin;
                }
            }

            // Reduce column by column
            for (int i = 0; i < matrix.GetMatrix().GetLength(0); i++)
            {
                // Only reduce the col if a cell in this col has NOT already been select as part of the path.
                if (state.GetCityFrom()[i] == -1)
                {
                    double colMin = double.PositiveInfinity;

                    for (int j = 0; j < matrix.GetMatrix().GetLength(0); j++)
                    {
                        if (matrix.GetMatrix()[j, i] < colMin)
                        {
                            colMin = matrix.GetMatrix()[j, i];
                        }
                    }

                    if (!double.IsInfinity(colMin))
                    {
                        for (int j = 0; j < matrix.GetMatrix().GetLength(0); j++)
                        {
                            matrix.GetMatrix()[j, i] -= colMin;
                        }
                    }

                    sumDifference += colMin;
                }
            }

            state.LowerBound += sumDifference;
            state.Matrix      = matrix;

            return(state);
        }