public static void dijkstra(int start) {
		int[] distances=new int[p];
		boolean[] visited=new boolean[p];
		Comparator<vertexButter> vComp = new VertexButterComparator();
		PriorityQueue<vertexButter> queue = new PriorityQueue<vertexButter>(p, vComp);
		for(int i=0; i<p; i++) {
			if(i!=startp[start]) {
				distances[i]=MAX;
			}
			else {
				distances[i]=0;
			}
			queue.add(new vertexButter(i, distances[i]));
		}
		// run dijkstra
		for(int i=0; i<p; i++) {
			vertexButter cur=queue.poll();
			while(visited[cur.v]) {
				cur=queue.poll();
			}
			visited[cur.v]=true;
			ArrayList<vertexButter> updated=new ArrayList<vertexButter>();
			for(int j=0; j<adj[cur.v].size(); j++) {
				int test=adj[cur.v].get(j);
				if(!visited[test]) {
					int alt=cur.d+graph[cur.v][test];
					if(alt<distances[test]) {
						vertexButter newV=new vertexButter(test, alt);
						distances[test]=alt;
						shortd[start][test]=alt;
						updated.add(newV);
					}
				}
			}
			for(int j=0; j<updated.size(); j++) {
				queue.add(updated.get(j));
			}
		}
	}