private void shortestPath() {
    IndexMinPQ<Integer> pq = new IndexMinPQ<Integer>(adjList.size());
    for (Map.Entry<Integer, Map<Integer, Integer>> entry : adjList.entrySet()) {
      int node = entry.getKey();
      if (node != source) {
        pq.insert(node, INTMAX);
      } else {
        pq.insert(node, 0);
      }
    }
    while (!pq.isEmpty()) {
      int distance = pq.minKey();
      int index = pq.delMin();
      dist.put(index, distance);
      Set<Integer> neighbors = adjList.get(index).keySet();
      for (int neighbor : neighbors) {
        if (!dist.containsKey(neighbor)) {
          int tmpDist = pq.delete(neighbor);
          int betweenDist = adjList.get(index).get(neighbor);
          if (distance + betweenDist < tmpDist) {
            pq.insert(neighbor, distance + betweenDist);
          } else {
            pq.insert(neighbor, tmpDist);
          }
        }
      }
    }
  }