Esempio n. 1
0
        public AllShortestPathsUsingMatrixMultiply(EdgeWeightedAdjMatrixDigraph g)
        {
            weights = g.Weights();
            int m = 1;

            while (m < g.V - 1)
            {
                weights = ExtendShortestPaths(weights);
                m       = 2 * m;
            }
        }
        public AllPairShortestPathsFloydWarshallAlgorithm(EdgeWeightedAdjMatrixDigraph g)
        {
            int n = g.V;

            double[,] weis0 = g.Weights();
            for (int k = 0; k < n; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        weis0[i, j] = System.Math.Min(weis0[i, j], weis0[i, k] + weis0[k, j]);
                    }
                }
            }
            weights = weis0;
        }