Package com.jgalgo.alg.shortestpath
Class ShortestPathHeuristicStAbstract
java.lang.Object
com.jgalgo.alg.shortestpath.ShortestPathHeuristicStAbstract
- All Implemented Interfaces:
ShortestPathHeuristicSt
- Direct Known Subclasses:
ShortestPathAStar
public abstract class ShortestPathHeuristicStAbstract
extends Object
implements ShortestPathHeuristicSt
Abstract class for computing shortest path between a source and a target with a heuristic.
The class implements the interface by solving the problem on the index graph and then maps the results back to the original graph. The implementation for index graphs is abstract and left to the subclasses.
- Author:
- Barak Ugav
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<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.computeShortestPath
(IntGraph g, IWeightFunction w, int source, int target, IntToDoubleFunction vHeuristic) Compute the shortest path between two vertices in an int graph.
-
Constructor Details
-
ShortestPathHeuristicStAbstract
public ShortestPathHeuristicStAbstract()Default constructor.
-
-
Method Details
-
computeShortestPath
public <V,E> Path<V,E> computeShortestPath(Graph<V, E> g, WeightFunction<E> w, V source, V target, ToDoubleFunction<V> vHeuristic) Description copied from interface:ShortestPathHeuristicSt
Compute the shortest path between two vertices in a graph.If
g
is anIntGraph
, aIPath
object will be returned. In that case, its better to pass aIWeightFunction
asw
to avoid boxing/unboxing.- Specified by:
computeShortestPath
in interfaceShortestPathHeuristicSt
- 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
source
totarget
-
computeShortestPath
public IPath computeShortestPath(IntGraph g, IWeightFunction w, int source, int target, IntToDoubleFunction vHeuristic) Description copied from interface:ShortestPathHeuristicSt
Compute the shortest path between two vertices in an int graph.- Specified by:
computeShortestPath
in interfaceShortestPathHeuristicSt
- 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
source
totarget
-