Interface ShortestPathSingleSource.IResult

    • Method Detail

      • distance

        double distance​(int target)
        Get the distance to a target vertex.
        Parameters:
        target - a target vertex in the graph
        Returns:
        the sum of the shortest path edges from the source to the target, or Double.POSITIVE_INFINITY if no such path found.
        Throws:
        NoSuchVertexException - if target is not a vertex in the graph
      • distance

        @Deprecated
        default double distance​(Integer target)
        Deprecated.
        Please use distance(int) instead to avoid un/boxing.
        Get the distance to a target vertex.
        Specified by:
        distance in interface ShortestPathSingleSource.Result<Integer,​Integer>
        Parameters:
        target - a target vertex in the graph
        Returns:
        the sum of the shortest path edges from the source to the target, or Double.POSITIVE_INFINITY if no such path found
      • getPath

        IPath getPath​(int target)
        Get shortest path to a target vertex.
        Parameters:
        target - a target vertex in the graph
        Returns:
        the shortest path from the source to the target or null if no such path found
        Throws:
        NoSuchVertexException - if target is not a vertex in the graph
      • backtrackEdge

        int backtrackEdge​(int target)
        Get the last edge on the shortest path from the source to the given target.

        The backtrack edge is an in-edge of the given target vertex. The set of all backtrack edges of all vertices define the shortest path tree of the source, and each shortest path can be constructed from them.

        Parameters:
        target - a target vertex in the graph
        Returns:
        the backtrack edge, the last edge on the shortest path from the source to th given target, or -1 if there is no path to the target or the target is the source
      • backtrackEdge

        @Deprecated
        default Integer backtrackEdge​(Integer target)
        Deprecated.
        Please use backtrackEdge(int) instead to avoid un/boxing.
        Get the last edge on the shortest path from the source to the given target.

        The backtrack edge is an in-edge of the given target vertex. The set of all backtrack edges of all vertices define the shortest path tree of the source, and each shortest path can be constructed from them.

        Specified by:
        backtrackEdge in interface ShortestPathSingleSource.Result<Integer,​Integer>
        Parameters:
        target - a target vertex in the graph
        Returns:
        the backtrack edge, the last edge on the shortest path from the source to th given target, or null if there is no path to the target or the target is the source
      • shortestPathTree

        default IntGraph shortestPathTree​(boolean directed)
        Description copied from interface: ShortestPathSingleSource.Result
        Get the shortest path tree, optionally directed or undirected.

        The shortest path tree is constructed from the vertices and edges used by any shortest path. It contains only the vertices reachable from the source, and for each vertex other than the source the graph will contains the edge that was used to reach it (see ShortestPathSingleSource.Result.backtrackEdge(Object)). If there are \(k\) reachable vertices, the graph will contain \(k-1\) edges.

        Specified by:
        shortestPathTree in interface ShortestPathSingleSource.Result<Integer,​Integer>
        Parameters:
        directed - if true the returned tree will be directed. If the original graph was undirected and a directed tree is created, the edges in the tree will be directed from the source towards the other vertices
        Returns:
        un/directed shortest path tree
      • sourceInt

        int sourceInt()
        Get the source vertex from which all shortest paths were computed from.
        Returns:
        the source vertex