Interface ShortestPathAllPairs

    • Method Detail

      • computeAllShortestPaths

        <V,​E> ShortestPathAllPairs.Result<V,​E> computeAllShortestPaths​(Graph<V,​E> g,
                                                                                   WeightFunction<E> 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.

        To compute the shortest cardinality (non weighted) paths, pass null instead of the weight function w.

        If g is an IntGraph, a ShortestPathAllPairs.IResult object will be returned. In that case, its better to pass a IWeightFunction as w to avoid boxing/unboxing.

        Type Parameters:
        V - the vertices type
        E - the edges type
        Parameters:
        g - a graph
        w - an edge weight function
        Returns:
        a result object containing information on the shortest path between each pair of vertices
        Throws:
        NegativeCycleException - if a negative cycle is detected in the graph
      • computeSubsetShortestPaths

        <V,​E> ShortestPathAllPairs.Result<V,​E> computeSubsetShortestPaths​(Graph<V,​E> g,
                                                                                      Collection<V> verticesSubset,
                                                                                      WeightFunction<E> w)
        Compute the shortest path between each pair of vertices in a given subset of the vertices of the graph.

        To compute the shortest cardinality (non weighted) paths, pass null instead of the weight function w.

        If g is an IntGraph, a ShortestPathAllPairs.IResult object will be returned. In that case, its better to pass a IWeightFunction as w and IntCollection as verticesSubset to avoid boxing/unboxing.

        Type Parameters:
        V - the vertices type
        E - the edges type
        Parameters:
        g - a graph
        verticesSubset - a subset of vertices of the graph. All shortest paths will be computed between each pair of vertices from the subset
        w - as edge weight function
        Returns:
        a result object containing information on the shortest path between each pair of vertices in the subset
        Throws:
        NegativeCycleException - if a negative cycle is detected in the graph. If there is a negative cycle that is not reachable from the set of given vertices, it might not be detected, depending on the implementation