import java.io.*; import java.util.*; public class dining { public static int[] dijkstra(Map cost, List> graph, final int N, int source) { int[] dist = new int[N]; PriorityQueue visited = new PriorityQueue(N,new Comparator() { @Override public int compare(Integer arg0, Integer arg1) { return Integer.compare(dist[arg0], dist[arg1]); //return 0; } }); Arrays.fill(dist, Integer.MAX_VALUE); dist[N-1] = 0; // Starting value //nodeQueue.add(N-1); visited.add(source); int u; while(!visited.isEmpty()) { //int u = nodeQueue.remove(); // Get next node u = visited.remove(); List adj = graph.get(u); for(int node:adj) { //if(dist[node] == Integer.MAX_VALUE) { // If this node has not been visited yet int edgeDist = cost.get(new Pair(u,node)); int totalDist = dist[u] + edgeDist; if (totalDist > graph = new ArrayList(M+1); for(int i = 0; i ()); } Map cost = new HashMap(); for(int i =0 ; i costWithHaybales = new HashMap(cost); System.out.println("Graph as an edgelist: "+graph); int[] taste = new int[K]; List bales = new ArrayList(); for(int i = 0; i