Package org.goplanit.algorithms.shortest
Class ShortestPathResultGeneralised
- java.lang.Object
-
- org.goplanit.algorithms.shortest.ShortestResultGeneralised
-
- org.goplanit.algorithms.shortest.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 behaviourNote 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 Summary
Fields Modifier and Type Field Description protected 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)-
Fields inherited from class org.goplanit.algorithms.shortest.ShortestResultGeneralised
getVertexAtExtreme, searchType, vertexMeasuredCost
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ShortestPathResultGeneralised(double[] vertexMeasuredCost, EdgeSegment[] nextEdgeSegmentByVertex, ShortestSearchType searchType)
Constructor only to be used by shortest path algorithms
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends SimpleDirectedPath>
TcreatePath(DirectedPathFactory<T> pathFactory, DirectedVertex origin, DirectedVertex destination)
Create the path from the provided origin to a specified destination vertex, using the results available.double
getCostOf(Vertex vertex)
Collect the cost to reach the given vertex from the reference starting pointEdgeSegment
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-
Methods inherited from class org.goplanit.algorithms.shortest.ShortestResultGeneralised
getNextVertexForEdgeSegment, getSearchType, getStartEndVertexForResultTraversal
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.algorithms.shortest.ShortestPathResult
forEachNextEdgeSegment
-
Methods inherited from interface org.goplanit.algorithms.shortest.ShortestResult
getNextVertexForEdgeSegment, getSearchType, isInverted
-
-
-
-
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 interfaceShortestPathResult
- Type Parameters:
T
- type of path- Parameters:
pathFactory
- to use for creating path instancesorigin
- the specified origin vertexdestination
- 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 interfaceShortestPathResult
- 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 interfaceShortestResult
- Parameters:
vertex
- to collect cost for- Returns:
- cost found
-
-