Package com.jgalgo

Interface ShortestPathAllPairs


  • public interface ShortestPathAllPairs
    An algorithm that compute all pairs shortest path (APSP) in a graph.

    The regular ShortestPathSingleSource can be used \(n\) times to achieve the same result, but it may be more efficient to use a APSP algorithm in the first place.

    Author:
    Barak Ugav
    • Method Detail

      • computeAllShortestPaths

        ShortestPathAllPairs.Result computeAllShortestPaths​(Graph g,
                                                            WeightFunction w)
        Compute the shortest path between each pair of vertices in a graph.

        Given an edge weight function, the length of a path is the weight sum of all edges of the path. The shortest path from a source vertex to some other vertex is the path with the minimum weight.

        Parameters:
        g - a graph
        w - an edge weight function
        Returns:
        a result object containing information on the shortest path between each pair of vertices
      • computeAllCardinalityShortestPaths

        default ShortestPathAllPairs.Result computeAllCardinalityShortestPaths​(Graph g)
        Compute the cardinality shortest path between each pair of vertices in a graph.

        The cardinality length of a path is the number of edges in it. The cardinality shortest path from a source vertex to some other vertex is the path with the minimum number of edges.

        Parameters:
        g - a graph
        Returns:
        a result object containing information on the cardinality shortest path between each pair of vertices