Class ShortestPathResultImpl
- java.lang.Object
-
- org.goplanit.algorithms.shortestpath.ShortestPathResultImpl
-
- All Implemented Interfaces:
ShortestPathResult
public class ShortestPathResultImpl extends Object implements ShortestPathResult
Class that stores the result of a shortest path execution allowing one to extract paths or cost information Note that we must traverse a path from an origin to a destination in reversed order to extract the path- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected EdgeSegment[]
incomingEdgeSegment
the preceding vertex to reach the vertex with the given measured costprotected double[]
vertexMeasuredCost
the costs found by a shortest path run
-
Constructor Summary
Constructors Modifier Constructor Description protected
ShortestPathResultImpl(double[] vertexMeasuredCost, EdgeSegment[] incomingEdgeSegment)
Constructor only to be used by shortest path algorithms
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DirectedPath
createPath(DirectedPathFactory pathFactory, Vertex origin, Vertex destination)
Create the path from the provided origin to a specified destination vertex, using the results available.double
getCostToReach(Vertex vertex)
Collect the cost to reach the given vertexEdgeSegment
getIncomingEdgeSegmentForVertex(Vertex vertex)
Find the incoming edge segment for a given vertex-
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.shortestpath.ShortestPathResult
forEachBackwardEdgeSegment
-
-
-
-
Field Detail
-
vertexMeasuredCost
protected final double[] vertexMeasuredCost
the costs found by a shortest path run
-
incomingEdgeSegment
protected final EdgeSegment[] incomingEdgeSegment
the preceding vertex to reach the vertex with the given measured cost
-
-
Constructor Detail
-
ShortestPathResultImpl
protected ShortestPathResultImpl(double[] vertexMeasuredCost, EdgeSegment[] incomingEdgeSegment)
Constructor only to be used by shortest path algorithms- Parameters:
vertexMeasuredCost
- measured costs to get to the vertex (by id)incomingEdgeSegment
- the incoming edge segment for each vertex (by id)
-
-
Method Detail
-
createPath
public DirectedPath createPath(DirectedPathFactory pathFactory, Vertex origin, Vertex 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
- 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
-
getIncomingEdgeSegmentForVertex
public EdgeSegment getIncomingEdgeSegmentForVertex(Vertex vertex)
Find the incoming edge segment for a given vertex- Specified by:
getIncomingEdgeSegmentForVertex
in interfaceShortestPathResult
- Parameters:
vertex
- to get incoming segment for- Returns:
- incoming edge segment
-
getCostToReach
public double getCostToReach(Vertex vertex)
Collect the cost to reach the given vertex- Specified by:
getCostToReach
in interfaceShortestPathResult
- Parameters:
vertex
- to collect cost for- Returns:
- cost found
-
-