public static void computeShortestPath(Gate sourceGate) {
    sourceGate.shortestTime = 0.;
    PriorityQueue<Gate> gateQueue = new PriorityQueue<Gate>();
    gateQueue.add(sourceGate);

    while (!gateQueue.isEmpty()) {
      Gate u = gateQueue.poll();

      // Visit each edge exiting u
      for (Edge e : u.adjacencies) {
        Gate v = e.destGate;
        double travelTime = e.travelTime;
        double timeThroughU = u.shortestTime + travelTime;
        if (timeThroughU < v.shortestTime) {
          gateQueue.remove(v);

          v.shortestTime = timeThroughU;
          v.previous = u;
          gateQueue.add(v);
        }
      }
    }
  }