input = DirectedGraph g, String start, String goal initialize pq as PriorityQueue, tree as List, startVertex as Vertex, goalVertex as Vertex call g.displayProperties.add("isVisited") startVertex = g.getVertex(start) startVertex.weight = 0 goalVertex = g.getVertex(goal) call pq.push(startVertex, 0) while tree.contains(goalVertex) = false initialize v as Vertex, weight as Integer v = pq.pop(weight) if v.isVisited != true then v.isVisited = true call tree.add(v) unvisitedNeighbors = unvisitedNeighbors(v) ask: call addToQueue(pq, v, unvisitedNeighbors, g) endIf endWhile say("The distance from start to goal is: ".concat(goalVertex.weight)) finish function unvisitedNeighbors(Vertex v) initialize neighbors as List forEach n in v.neighbors if n.isVisited != true then call neighbors.add(n) endIf next return neighbors endFunction function addToQueue(PriorityQueue pq, Vertex v, List unvisitedNeighbors, DirectedGraph g) forEach n in unvisitedNeighbors initialize weight as Integer weight = v.weight + g.d(v, n) if pq.contains(n) = true then if n.weight > weight then n.parent = v.value n.weight = weight call pq.push(n, weight) endIf else n.parent = v.value n.weight = weight call pq.push(n, weight) endIf next return "" endFunction