public static int dijkstra(int[][] map, int start, int end) {
    	int n=map.length;
    	int[]d=new int[n]; Arrays.fill(d, -1); d[start]=0;
    	Queue<Integer>pq=new PriorityQueue<>((a,b)->(d[a]-d[b])); pq.offer(start);
    	while (!pq.isEmpty()) {
    		int cn=pq.poll();
    		for (int i=0;i<n;++i) {
    			if (map[cn][i]>0&&(d[i]==-1||d[cn]+map[cn][i]<d[i])) {
    				d[i]=d[cn]+map[cn][i];
    				pq.offer(i);
    			}
    		}
    	}
    	return d[end];
    }