Esempio n. 1
0
        private void Floyd(AdjacencyMatrix matrix)
        {
            var count = matrix.Count;

            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < count; j++)
                {
                    if (matrix.Get(i, j) == 0)
                    {
                        matrix.Set(100000, i, j);
                    }
                }
            }

            for (int k = 0; k < count; k++)
            {
                for (int i = 0; i < count; i++)
                {
                    for (int j = 0; j < count; j++)
                    {
                        var sum = matrix.Get(i, k) + matrix.Get(k, j);

                        if (matrix.Get(i, j) > sum)
                        {
                            matrix.Set(sum, i, j);
                        }
                    }
                }
            }

            for (int i = 0; i < count; i++)
            {
                matrix.Set(0, i, i);
            }
        }
Esempio n. 2
0
 public LogisticCenterService(AdjacencyMatrix adjacencyMatrix)
 {
     this.adjacencyMatrix = adjacencyMatrix
                            ?? throw new ArgumentNullException(nameof(adjacencyMatrix));
 }