BridgeTheGap.java
/**
	 * implementation of Dijkstra's algorithm, sorting by distance from center
	 */
implementation of Dijkstra's algorithm, sorting by distance from center
implementation of Dijkstra ' s algorithm sorting by distance from center
public void Dijkstra(String center) {
		Vertex centerV = vertexMap.get(center); 
		PriorityQueue<Vertex> priorityQ = new PriorityQueue<Vertex>(); 
		priorityQ.add(centerV);
		while (priorityQ.size() > 0) { 
			Vertex headOfQ = priorityQ.poll();
			headOfQ.isGreen = true;
			for (Edge e : headOfQ.links) {
				Vertex dest = e.otherend;
				if (dest.isGray) {
					dest.isYellow = true;
					dest.isGray = false;
					dest.distance += 1; 
					dest.prev = headOfQ;
					priorityQ.add(dest);
				} else {
					dest.distance += 1;
					dest.prev = headOfQ;
				}
			}
			Collection c = vertexMap.values();
			java.util.Iterator itr = c.iterator();
			while (itr.hasNext()){
				Vertex v = (Vertex) itr.next();
			}
		}
	}
public void Dijkstra ( String center ) { Vertex centerV = vertexMap . get ( center ) ; PriorityQueue < Vertex > priorityQ = new PriorityQueue < Vertex > ( ) ; priorityQ . add ( centerV ) ; while ( priorityQ . size ( ) > 0 ) { Vertex headOfQ = priorityQ . poll ( ) ; headOfQ . isGreen = true ; for ( Edge e : headOfQ . links ) { Vertex dest = e . otherend ; if ( dest . isGray ) { dest . isYellow = true ; dest . isGray = false ; dest . distance += 1 ; dest . prev = headOfQ ; priorityQ . add ( dest ) ; } else { dest . distance += 1 ; dest . prev = headOfQ ; } } Collection c = vertexMap . values ( ) ; java . util . Iterator itr = c . iterator ( ) ; while ( itr . hasNext ( ) ) { Vertex v = ( Vertex ) itr . next ( ) ; } } }
implementation of Dijkstra's algorithm, sorting by distance from center
implementation of Dijkstra ' s algorithm sorting by distance from center
//gets the vertex from TreeMap // Does priority queue automatically re-sort? //instantiate priority queue - will need to set its comparator based on length of edge list? Idk //while all nodes have not been visited //for every vertex in the vertex's edgeList //do I need to remove this from the original queue? //might not be 1, might be something else //System.out.println("distance from center of "+ v.name + " " + v.distance);