With Dijkstra you use the end-condition
while(!q.isEmpty()){
//Some code
}
But if you know the end node, is it not possible to change the end-condition to
while(!q.peek().equals(endNode){
//Some code
}
Every implementation of Dijkstra I have seen uses the earlier, but the later is faster when you know the end node. Or is this not Dijkstra anymore?