/**
  * Dijkstra doesn't allow negative edge weights so throw an exception if one was found.
  *
  * @throws IllegalArgumentException if the graph contains negative weights
  */
 private void checkForNegativeWeights() {
   for (Edge e : graph.getEdges()) {
     if (e.getWeight() < 0) {
       throw new IllegalArgumentException("graph contains negative weights!");
     }
   }
 }
  private void executeDijkstra() {
    // determine minimum distance vertex and add it to the path.
    while (!this.priorityQueue.isEmpty()) {
      Vertex vertex = this.priorityQueue.extractMin();

      for (Edge e : graph.getIncidentEdgesOf(vertex)) {
        relax(vertex, e.getVertexB(), e.getWeight(), dist, pred);
      }
    }
  }