public static Set<GraphNode> Dijkstra(GraphNode origin, List<GraphNode> nodes) {
		Set<GraphNode> visited = new HashSet<GraphNode>();
		
		PriorityQueue<GraphNode> frontier = new PriorityQueue<GraphNode>(10, new GraphNodeComparator());
		for (int i = 1; i < nodes.size(); i++) {
			frontier.add(nodes.get(i));
		}
		
		GraphNode current = origin;
		current.cost = 0;
		
		while (true) {
			visited.add(current);
			for (GraphEdge candidate : current.edges) {
				GraphNode otherEnd = candidate.otherEnd(current);
				if (!visited.contains(otherEnd)) {
					if (otherEnd.cost > current.cost + candidate.cost) {
						// TODO: It would be neat to store the path to this node as well.
						otherEnd.cost = current.cost + candidate.cost;
					}
				}
			}
			if (!frontier.isEmpty()) {
				current = frontier.remove();
			} else {
				break;
			}
		}
		
		return visited;
	}