Make the vweighter
and h
parameters final:
shortestPath(Graph<VLabel, ELabel> G,
Graph<VLabel, ELabel>.Vertex V0,
Graph<VLabel, ELabel>.Vertex V1,
final Distancer<? super VLabel> h, //heuristic value
final Weighter<? super VLabel> vweighter,
Weighting<? super ELabel> eweighter) {
EDIT:
If you for some reason aren't allowed to use the final operator on the parameter variables you can redeclare them:
final Distancer<? super VLabel> myH = h;
final Weighter<? super VLabel> myVweighter = vWeighter;
And then use the redeclared variables in the comparator.
UPDATE 2:
If you want to make a class that implements the comparable interface and you want to change the functions as you go, this is how you would make that class:
public class WeightComparator implements
Comparator<Graph<VLabel, ELabel>.Vertex> {
private Graph<VLabel, ELabel> G;
private Graph<VLabel, ELabel>.Vertex V0;
private Graph<VLabel, ELabel>.Vertex V1;
private Distancer<? super VLabel> h; //heuristic value
private Weighter<? super VLabel> vweighter;
private Weighting<? super ELabel> eweighter;
public WeightComparator() {
}
@Override
public int compare(Graph<VLabel, ELabel>.Vertex o1, Graph<VLabel, ELabel>.Vertex o2) {
// Your compare statement
}
// Getters and setters for all variables
}
When instanciating it you should keep the reference and update the variables as needed.