Class ShortestPathResultGeneralised

  • All Implemented Interfaces:
    ShortestPathResult, ShortestResult

    public class ShortestPathResultGeneralised
    extends ShortestResultGeneralised
    implements ShortestPathResult
    Class that stores the result of a shortest path execution allowing one to extract paths or cost information. Can be used for a one-to-all as well as an all-to-one search result. However not both at the same time, so either the internal state reflects a one-to-all result, or an all-to-one result and methods supported by that specific interface have defined behaviour

    Note that for one-to-all we traverse a path from an origin to a destination in reversed order to extract the path, whereas in all-to-one we can directly extract it as we start at the origin directly.

    Author:
    markr
    • Field Detail

      • nextEdgeSegmentByVertex

        protected final EdgeSegment[] nextEdgeSegmentByVertex
        the next edge segment to reach the vertex with the given measured cost (preceding in one-to-all, succeeding in all-to-one)
    • Constructor Detail

      • ShortestPathResultGeneralised

        protected ShortestPathResultGeneralised​(double[] vertexMeasuredCost,
                                                EdgeSegment[] nextEdgeSegmentByVertex,
                                                ShortestSearchType searchType)
        Constructor only to be used by shortest path algorithms
        Parameters:
        vertexMeasuredCost - measured costs to get to the vertex (by id)
        nextEdgeSegmentByVertex - the next edge segment for each vertex (by id)
        searchType - used (one-to-all, all-to-one, etc)
    • Method Detail

      • createPath

        public <T extends SimpleDirectedPath> T createPath​(DirectedPathFactory<T> pathFactory,
                                                           DirectedVertex origin,
                                                           DirectedVertex destination)
        Create the path from the provided origin to a specified destination vertex, using the results available. The path builder is used to create the instance of the path.
        Specified by:
        createPath in interface ShortestPathResult
        Type Parameters:
        T - type of path
        Parameters:
        pathFactory - to use for creating path instances
        origin - the specified origin vertex
        destination - the specified destination vertex
        Returns:
        the path that is created, when no path could be extracted null is returned
      • getNextEdgeSegmentForVertex

        public EdgeSegment getNextEdgeSegmentForVertex​(Vertex vertex)
        Find the next edge segment for a given vertex, depending on the underlying search this can be either in upstream or downstream direction
        Specified by:
        getNextEdgeSegmentForVertex in interface ShortestPathResult
        Parameters:
        vertex - to get next segment for
        Returns:
        next edge segment
      • getCostOf

        public double getCostOf​(Vertex vertex)
        Collect the cost to reach the given vertex from the reference starting point
        Specified by:
        getCostOf in interface ShortestResult
        Parameters:
        vertex - to collect cost for
        Returns:
        cost found