public abstract class Dijkstra { private static final int INFINITE = Integer.MAX_VALUE; protected InspectableGraph graph; protected PriorityQueue Q; // priority queue used by the algorithm public Object execute(InspectableGraph g, Vertex start) { graph = g; dijkstraVisit(start); return distances(); } // initialization abstract void init(); // create an empty priority queue abstract PriorityQueue initPQ(Comparator comp); // return the weight of edge e abstract int weight(Edge e); // attach to u its locator loc in Q abstract void setLocator(Vertex u, Locator loc); // return the locator attached to u abstract Locator getLocator(Vertex u); // attach to u its distance dist abstract void setDistance(Vertex u, int dist); // return the vertex distances in a data structure abstract Object distances(); // return as an int the key of a vertex in Q private int value(Locator u_loc) { return ((Integer) u_loc.key()).intValue(); }