Class AStarAlgorithm

java.lang.Object
org.graph4j.GraphAlgorithm
org.graph4j.shortestpath.AStarAlgorithm
All Implemented Interfaces:
SinglePairShortestPath

public class AStarAlgorithm extends GraphAlgorithm implements SinglePairShortestPath
A* algorithm finds the shortest path from a specified source vertex to a specified target vertex. The algorithm is guided by a heuristic function h(v) that estimates the distance from the vertex v to the target. Dijkstra's algorithm can be viewd as a special case of A* where no heuristic function is available: h(v)=0, for all v.
Author:
Cristian Ivan, Cristian Frăsinaru
  • Field Details

    • source

      protected final int source
    • target

      protected final int target
    • vertices

      protected final int[] vertices
    • cost

      protected double[] cost
    • before

      protected int[] before
    • size

      protected int[] size
    • solved

      protected boolean[] solved
    • numSolved

      protected int numSolved
  • Constructor Details

    • AStarAlgorithm

      public AStarAlgorithm(Graph graph, int source, int target, AStarEstimator heuristic)
      Creates an algorithm to find the shortest path between source and target.
      Parameters:
      graph - the input graph.
      source - the source vertex number.
      target - the target vertex number.
      heuristic - the estimated distance from a vertex to the target.
  • Method Details