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())
...