cdragomir

wsyuwd

Apr 20th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. while (selected.size() < g.size() && !pq.isEmpty()) {
  2.             boolean can_continue = false;
  3.             NodeT<String> u = null;
  4.             while (!pq.isEmpty()) {
  5.                 u = pq.poll();
  6.                 if (!selected.contains(u)) {
  7.                     selected.add(u);
  8.                     can_continue = true;
  9.                     break;
  10.                 }
  11.             }
  12.             if (!can_continue) {
  13.                 break;
  14.             }
  15.             for (PairT<NodeT<String>, Integer> pair : g.adjList(u)) {
  16.                 if (!selected.contains(pair.first())
  17.                         && distances[g.indexOf(pair.first())] > distances[g.indexOf(u)] + g.distance(u, pair.first())) {
  18.                     distances[g.indexOf(pair.first())] = distances[g.indexOf(u)] + g.distance(u, pair.first());
  19.                     pq.offer(pair.first());
  20.                 }
  21.                
  22.             }
  23.         }
Add Comment
Please, Sign In to add comment