Package org.goplanit.algorithms.shortest
Class ShortestPathDijkstra
- java.lang.Object
-
- org.goplanit.algorithms.shortest.ShortestPathGeneralised
-
- org.goplanit.algorithms.shortest.ShortestPathDijkstra
-
- All Implemented Interfaces:
ShortestPathAllToOne
,ShortestPathOneToAll
public class ShortestPathDijkstra extends ShortestPathGeneralised implements ShortestPathOneToAll, ShortestPathAllToOne
Dijkstra's shortest path algorithm Dijkstra's shortest path is a one-to-all (or all-to-one) implementation of the shortest path algorithm based on the generalized costs on each link segment (edge). The costs should be provided upon instantiation and are reused whenever an execution conditional on the chosen source/destination node is performed. In its current form, it assumes a macroscopic network and macroscopic link segments to operate on- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected static BiPredicate<Double,Double>
isShorterPredicate
predicate for Dijkstra where shortest means less cost than existing cost, so only cheaper paths overwrite an existing shortest path to a nodeprotected EdgeSegment[]
shortestEdgeSegmentOfVertex
Track incoming edge segment that is shortest for each vertex in this array-
Fields inherited from class org.goplanit.algorithms.shortest.ShortestPathGeneralised
currentSource, edgeSegmentCosts, getEdgeSegmentsInDirection, getVertexAtExtreme, numberOfVertices
-
-
Constructor Summary
Constructors Constructor Description ShortestPathDijkstra(double[] edgeSegmentCosts, int numberOfVertices)
Constructor for an edge cost based Dijkstra algorithm for finding shortest paths.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ShortestPathResult
execute(ShortestSearchType searchType, DirectedVertex startVertex)
Execute shortest path search based on given search direction and start vertexShortestPathResult
executeAllToOne(DirectedVertex currentDestination)
Construct shortest paths from all nodes to a single sink node in the network based on directed Link segment edgesShortestPathResult
executeOneToAll(DirectedVertex currentOrigin)
Construct shortest paths from source node to all other nodes in the network based on directed LinkSegment edges-
Methods inherited from class org.goplanit.algorithms.shortest.ShortestPathGeneralised
execute, executeAllToOne, executeOneToAll, getEdgeSegmentCost, initialiseOpenVertices, internalExecute
-
-
-
-
Field Detail
-
shortestEdgeSegmentOfVertex
protected EdgeSegment[] shortestEdgeSegmentOfVertex
Track incoming edge segment that is shortest for each vertex in this array
-
isShorterPredicate
protected static final BiPredicate<Double,Double> isShorterPredicate
predicate for Dijkstra where shortest means less cost than existing cost, so only cheaper paths overwrite an existing shortest path to a node
-
-
Constructor Detail
-
ShortestPathDijkstra
public ShortestPathDijkstra(double[] edgeSegmentCosts, int numberOfVertices)
Constructor for an edge cost based Dijkstra algorithm for finding shortest paths.- Parameters:
edgeSegmentCosts
- edge segment costs both physical and virtualnumberOfVertices
- Vertices, both nodes and centroids
-
-
Method Detail
-
execute
public ShortestPathResult execute(ShortestSearchType searchType, DirectedVertex startVertex)
Execute shortest path search based on given search direction and start vertex- Parameters:
searchType
- to usestartVertex
- to use- Returns:
- results of shortest path search, if something went wrong null is returned
-
executeOneToAll
public ShortestPathResult executeOneToAll(DirectedVertex currentOrigin)
Construct shortest paths from source node to all other nodes in the network based on directed LinkSegment edges- Specified by:
executeOneToAll
in interfaceShortestPathOneToAll
- Parameters:
currentOrigin
- origin vertex of source node- Returns:
- shortest path result that can be used to extract paths
-
executeAllToOne
public ShortestPathResult executeAllToOne(DirectedVertex currentDestination)
Construct shortest paths from all nodes to a single sink node in the network based on directed Link segment edges- Specified by:
executeAllToOne
in interfaceShortestPathAllToOne
- Parameters:
currentDestination
- destination vertex- Returns:
- shortest path result that can be used to extract paths
-
-