N
- node classE
- edge classpublic class DijkstraSSSP<N,E> extends Object implements SSSPResult<N,E>
Constructor and Description |
---|
DijkstraSSSP(Graph<N,E> graph,
N init,
EdgeWeights<E> edgeWeights)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
findSSSP()
Start the search.
|
static <N,E> SSSPResult<N,E> |
findSSSP(Graph<N,E> graph,
N init,
EdgeWeights<E> edgeWeights)
Search for the shortest paths from a single source node in a graph.
|
N |
getInitialNode()
Retrieves the node the source was started from.
|
List<E> |
getShortestPath(N target)
Retrieves the shortest path from the initial node to the given one (as a sequence of edges),
or null if there exists no such path.
|
float |
getShortestPathDistance(N target)
Retrieves the length of the shortest path from the initial node
to the given one.
|
E |
getShortestPathEdge(N target)
Retrieves the incoming edge via which the given node is reached on the shortest path.
|
public DijkstraSSSP(Graph<N,E> graph, N init, EdgeWeights<E> edgeWeights)
graph
- the graph in which to search for shortest pathsinit
- the initial nodeedgeWeights
- the edge weightspublic static <N,E> SSSPResult<N,E> findSSSP(Graph<N,E> graph, N init, EdgeWeights<E> edgeWeights)
graph
- the graph in which to perform the searchinit
- the initial (source) nodeedgeWeights
- the edge weightspublic void findSSSP()
public float getShortestPathDistance(N target)
SSSPResult
getShortestPathDistance
in interface SSSPResult<N,E>
target
- the target nodeGraphAlgorithms#INVALID_DISTANCE
if there exists no
such path.public List<E> getShortestPath(N target)
SSSPResult
Note that implementations might construct these paths on-the-fly.
getShortestPath
in interface SSSPResult<N,E>
target
- the target nodepublic N getInitialNode()
SSSPResult
getInitialNode
in interface SSSPResult<N,E>
public E getShortestPathEdge(N target)
SSSPResult
getShortestPathEdge
in interface SSSPResult<N,E>
target
- the target nodeCopyright © 2015. All Rights Reserved.