예제 #1
0
        private Cell[,] Normalize(CostMatrix matrix)
        {
            int vertexCount = matrix.Matrix.GetLength(0);

            Cell[,] normalized = new Cell[vertexCount, vertexCount];

            for (int i = 0; i < vertexCount; i++)
            {
                for (int j = 0; j < vertexCount; j++)
                {
                    int minDistance = GetMinVertexDistance(matrix.Edges, i, j, vertexCount);

                    if (i != j && matrix.Matrix[i, j] == Infinity)
                    {
                        normalized[i, j] = new Cell(i, j, i, j, minDistance, false);
                    }
                    else
                    {
                        int cellValue = i != j ? minDistance : matrix.Matrix[i, j];
                        normalized[i, j] = new Cell(i, j, i, j, cellValue, true);
                    }
                }
            }

            return(normalized);
        }
예제 #2
0
        private CostMatrix G2()
        {
            var matrix = new CostMatrix(4);

            matrix.AddEdge(0, 1, 42);
            matrix.AddEdge(0, 2, 30);
            matrix.AddEdge(0, 3, 12);
            matrix.AddEdge(1, 0, 42);
            matrix.AddEdge(1, 2, 20);
            matrix.AddEdge(1, 3, 35);
            matrix.AddEdge(2, 0, 30);
            matrix.AddEdge(2, 1, 20);
            matrix.AddEdge(2, 3, 34);
            matrix.AddEdge(3, 0, 12);
            matrix.AddEdge(3, 1, 35);
            matrix.AddEdge(3, 2, 34);

            return(matrix);
        }
예제 #3
0
        private CostMatrix G1()
        {
            var matrix = new CostMatrix(7);

            matrix.AddEdge(0, 1, 12);
            matrix.AddEdge(1, 0, 12);
            matrix.AddEdge(1, 2, 10);
            matrix.AddEdge(2, 1, 10);
            matrix.AddEdge(3, 2, 17);
            matrix.AddEdge(0, 3, 28);
            matrix.AddEdge(3, 0, 28);
            matrix.AddEdge(1, 3, 43);
            matrix.AddEdge(3, 1, 43);
            matrix.AddEdge(4, 1, 31);
            matrix.AddEdge(2, 4, 10);
            matrix.AddEdge(4, 2, 10);
            matrix.AddEdge(4, 5, 8);
            matrix.AddEdge(5, 4, 14);
            matrix.AddEdge(5, 6, 6);
            matrix.AddEdge(6, 5, 6);

            return(matrix);
        }
예제 #4
0
 public LittleAlgotithm(CostMatrix originalMatrix)
 {
     this.originalMatrix  = originalMatrix;
     this.vertexDistances = new VertexShortDistancesResult[originalMatrix.Matrix.GetLength(0)];
 }