Exemplo n.º 1
0
 public object Clone()
 {
     AdjacencyMatrix newMatrix = new AdjacencyMatrix(this.NodeCount);
     for (int i = 0; i < this.matrix.Length; i++)
     {
         for (int j = 0; j < this.matrix[i].Length; j++)
         {
             if (this.matrix[i][j].HasValue) { newMatrix.AddEdge(i, j, this.matrix[i][j].Value); }
         }
     }
     return newMatrix;
 }
Exemplo n.º 2
0
 public void AlgoritmStep()
 {
     for (int k = 0; k < previousMatrix.NodeCount; k++)
     {
         for (int i = 0; i < previousMatrix.NodeCount; i++)
         {
             for (int j = 0; j < previousMatrix.NodeCount; j++)
             {
                 if ((previousMatrix.GetElement(i,k).HasValue)&&(previousMatrix.GetElement(k,j).HasValue))
                 {
                     int prev = previousMatrix.GetElement(i,j) ?? Int32.MaxValue;
                     int next = previousMatrix.GetElement(i,k).Value + previousMatrix.GetElement(k,j).Value;
                     nextMatrix.SetElement(i,j, prev <= next ? prev : next);
                 }
             }
         }
         previousMatrix = (AdjacencyMatrix)nextMatrix.Clone();
     }
 }
Exemplo n.º 3
0
 public FlWaAlgoritm(AdjacencyMatrix inputMatrix)
 {
     previousMatrix = (AdjacencyMatrix)inputMatrix.Clone();
     nextMatrix = (AdjacencyMatrix)inputMatrix.Clone();
 }