1. private void shortestPath(Intersection start, List<Intersection> inters)
  2. {
  3. for(Intersection i : inters)
  4. {
  5. i.setK(false);
  6. i.setP(null);
  7. i.setD(INFINITY);
  8. }
  9.  
  10. Heap<Intersection> h = new Heap<Intersection>();
  11. start.setD(0.0);
  12. h.insert(start.getD(), start);
  13. do
  14. {
  15. Intersection i = h.remove();
  16.  
  17. if(i.isK() == false)
  18. {
  19. i.setK(true);
  20.  
  21. for(Road r : i.getAdjacent())
  22. {
  23. Intersection next = r.getIntersection2();
  24. if(next.getD() > i.getD() + r.getCost(measure))
  25. {
  26. next.setD(i.getD() + r.getCost(measure));
  27. next.setP(i);
  28. h.insert(next.getD(), next);
  29. }
  30. }
  31. }
  32. }
  33. while(!h.isEmpty());
  34. }