// relax edge e and update pq if changed
 private void relaxC(Route r, int v) {
   City city2 = r.other(cities[v]);
   int w = city2.id() - 1;
   if (costTo[w] > costTo[v] + r.price()) {
     costTo[w] = costTo[v] + r.price();
     edgeTo[w] = r;
     if (costPQ.contains(w)) costPQ.change(w, costTo[w]);
     else costPQ.insert(w, costTo[w]);
   }
 }
 private void relaxD(Route r, int v) {
   // relax edge e and update pq if changed
   City city2 = r.other(cities[v]);
   int w = city2.id() - 1;
   if (distTo[w] > distTo[v] + r.distance()) {
     distTo[w] = distTo[v] + r.distance();
     edgeTo[w] = r;
     if (pq.contains(w)) pq.change(w, distTo[w]);
     else pq.insert(w, distTo[w]);
   }
 }
 private void scan(int v) {
   marked[v] = true;
   for (Route r : adj[v]) {
     int w = r.other(cities[v]).id() - 1; // index of other city in route
     if (marked[w]) {
       continue; // v-w is obsolete edge
     }
     if (r.distance() < distTo[w]) {
       distTo[w] = r.distance();
       edgeTo[w] = r;
       if (pq.contains(w)) {
         pq.change(w, distTo[w]);
       } else {
         pq.insert(w, distTo[w]);
       }
     }
   }
 }