Implementing an A* algorithm

We will now look at how to implement an A* algorithm. Let's start with the code. We will use the same code that we used in the Dijkstra's search algorithm. The Vertex.java file is as follows:

public class Vertex {    final private String id;    final private String name;    public Vertex(String id, String name) {        this.id = id;        this.name = name;    }// public String getId() {// return id;// }//// public String getName() {// return name;// }    @Override    public int hashCode() {        final int prime = 31;        int result = 1;        result = prime * result + ((id == null) ? 0 : id.hashCode());        return result;    }    @Override    public boolean equals(Object obj) {        if (this == obj)            return true;        if (obj == null)            return false; if (getClass() != obj.getClass()) ...

Get Hands-On Artificial Intelligence with Java for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.