public AllShortestPathsUsingMatrixMultiply(EdgeWeightedAdjMatrixDigraph g) { weights = g.Weights(); int m = 1; while (m < g.V - 1) { weights = ExtendShortestPaths(weights); m = 2 * m; } }
/// <summary> /// Constructor /// </summary> /// <param name="g"></param> public AllPairShortestPaths(EdgeWeightedAdjMatrixDigraph g) { int n = g.V; weights = new double[n, n]; hasPathTo = new bool[n, n]; pathTo = new List <DirectedEdge> [n, n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { weights[i, j] = double.PositiveInfinity; } } }
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; }
public AllPairShortestPathsUsingJohnsonForSparseGraph(EdgeWeightedAdjMatrixDigraph g) : base(g) { }