public void ValidateBuildFromUpperRow()
        {
            MatrixBuilder builder = new MatrixBuilder();
            int dimension = 4;
            double[] input =
            {
                 1,  2,  3,  // only top right triangle w/o diagonal, read by rows
                     4,  5, 
                         6,                 
            };
            double[,] expectedOutput =
            {
                { 0, 1, 2, 3 },
                { 1, 0, 4, 5 },
                { 2, 4, 0, 6 },
                { 3, 5, 6, 0 }
            };

            var output = builder.BuildFromUpperRow(input, dimension);
            AssertArraysAreEqual(expectedOutput, output);
        }
        /// <summary>
        /// Loads weight matrix from tsp data
        /// </summary>
        /// <returns>Edge weight matrix</returns>
        protected double[,] LoadWeightMatrix()
        {
            MatrixBuilder matrixBuilder = new MatrixBuilder();
            switch (tspFile.EdgeWeightFormat)
            {
                case Defines.EdgeWeightFormat.FullMatrix:
                    return matrixBuilder.BuildFromFullMatrix(tspFile.EdgeWeights, tspFile.Dimension);

                case Defines.EdgeWeightFormat.UpperRow:
                case Defines.EdgeWeightFormat.LowerColumn:
                    return matrixBuilder.BuildFromUpperRow(tspFile.EdgeWeights, tspFile.Dimension);

                case Defines.EdgeWeightFormat.LowerRow:
                case Defines.EdgeWeightFormat.UpperColumn:
                    return matrixBuilder.BuildFromLowerRow(tspFile.EdgeWeights, tspFile.Dimension);

                case Defines.EdgeWeightFormat.UpperDiagonalRow:
                case Defines.EdgeWeightFormat.LowerDiagonalColumn:
                    return matrixBuilder.BuildFromUpperDiagonalRow(tspFile.EdgeWeights, tspFile.Dimension);

                case Defines.EdgeWeightFormat.LowerDiagonalRow:
                case Defines.EdgeWeightFormat.UpperDiagonalColumn:
                    return matrixBuilder.BuildFromLowerDiagonalRow(tspFile.EdgeWeights, tspFile.Dimension);

                default:
                    throw new NotSupportedException();
            }
        }
 public void BuildFromUpperRow_DimensionsDoesNotFitInputData_ThrowsException()
 {
     MatrixBuilder builder = new MatrixBuilder();
     builder.BuildFromUpperRow(new double[] { 1, 2, 3, 4, 5, 6 }, 10);
     Assert.Fail();
 }