java.lang.Object
io.github.tigerbotics7125.tigerlib.math.graph.AStar<T>

public class AStar<T> extends Object
This class represents an A* algorithm as a class, which can be used continueously over its Graph.
Since:
2023
  • Constructor Details

    • AStar

      public AStar(Graph<T> graph, Function<Tuple<Vertex<T>,Vertex<T>>,Double> hFunc)
      Parameters:
      graph - The Graph of which this AStar instance will operate over.
      hFunc - The function which calculates the heuristic from any two Verticies.
  • Method Details

    • h

      public double h(Vertex<T> v1, Vertex<T> v2)
      Shortcut for accessing the heuristic function.
      Parameters:
      v1 -
      v2 -
      Returns:
      The heuristic between the two Verticies.
    • genPath

      public List<Vertex<T>> genPath(Map<Vertex<T>,Vertex<T>> cameFrom, Vertex<T> vertex)
      Generate the path from their Vertex to Vertex mapping.
      Parameters:
      cameFrom - Map representing which Vertex "cameFrom" which Vertex.
      vertex - The last vertex in the list.
      Returns:
      The ordered list of verticies held in the map.
    • astar

      public List<Vertex<T>> astar(Vertex<T> start, Vertex<T> end)
      Parameters:
      start - The starting Vertex.
      end - The ending, goal Vertex.
      Returns:
      The list of Verticies, start to end, which represents the most cost effecient way of traversing the graph.