Interface ShortestPathHeuristicST
-
public interface ShortestPathHeuristicSTShortest path algorithm that uses a distance heuristic function.Given a source and target vertices, and a heuristic function that maps each vertex to distance approximation of its distance to the target, the algorithm attempt to find the shortest path from the source to target. An advantage of such algorithm over other
ShortestPathSingleSourcealgorithms, is that it can terminate much faster for the specific source and target, especially if the heuristic is good.Differing from the regular
ShortestPathSingleSource, algorithms implementing this interface attempt to find the shortest path between a single source and a single target, rather than a single source and all other vertices as targets. Therefore, the algorithm can terminate after performing and using less than linear (in the graph size) operations and space.Use
newInstance()to get a default implementation of this interface. A builder obtained vianewBuilder()may support different options to obtain different implementations.- Author:
- Barak Ugav
- See Also:
ShortestPathSingleSource
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceShortestPathHeuristicST.BuilderA builder forShortestPathHeuristicSTobjects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
Path<V,E>computeShortestPath(Graph<V,E> g, WeightFunction<E> w, V source, V target, ToDoubleFunction<V> vHeuristic)Compute the shortest path between two vertices in a graph.IPathcomputeShortestPath(IntGraph g, IWeightFunction w, int source, int target, IntToDoubleFunction vHeuristic)Compute the shortest path between two vertices in an int graph.static ShortestPathHeuristicST.BuildernewBuilder()Create a new heuristic shortest path algorithm builder.static ShortestPathHeuristicSTnewInstance()Create a new shortest path algorithm with heuristic.
-
-
-
Method Detail
-
computeShortestPath
<V,E> Path<V,E> computeShortestPath(Graph<V,E> g, WeightFunction<E> w, V source, V target, ToDoubleFunction<V> vHeuristic)
Compute the shortest path between two vertices in a graph.If
gis anIntGraph, aIPathobject will be returned. In that case, its better to pass aIWeightFunctionaswto avoid boxing/unboxing.- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- a graphw- an edge weight functionsource- a source vertextarget- a target vertexvHeuristic- a heuristic function that map each vertex todouble. The heuristic should be close to the real distance of each vertex to the target.- Returns:
- the short path found from
sourcetotarget
-
computeShortestPath
IPath computeShortestPath(IntGraph g, IWeightFunction w, int source, int target, IntToDoubleFunction vHeuristic)
Compute the shortest path between two vertices in an int graph.- Parameters:
g- a graphw- an edge weight functionsource- a source vertextarget- a target vertexvHeuristic- a heuristic function that map each vertex todouble. The heuristic should be close to the real distance of each vertex to the target.- Returns:
- the short path found from
sourcetotarget
-
newInstance
static ShortestPathHeuristicST newInstance()
Create a new shortest path algorithm with heuristic.This is the recommended way to instantiate a new
ShortestPathHeuristicSTobject. TheShortestPathHeuristicST.Buildermight support different options to obtain different implementations.- Returns:
- a default implementation of
ShortestPathHeuristicST
-
newBuilder
static ShortestPathHeuristicST.Builder newBuilder()
Create a new heuristic shortest path algorithm builder.Use
newInstance()for a default implementation.- Returns:
- a new builder that can build
ShortestPathHeuristicSTobjects
-
-