All pastes #966136 Raw Edit

Miscellany

public java v1 · immutable
·published 2008-04-01 14:43 UTC
rendered paste body
private static void bfs(UndirectedGraph g, int f, int t) throws IOException{		queue.offer(new Integer(f));		boolean found = false;		boolean nopath = false;		while(!found || !nopath){			if(graph.degree(f)>0){				int tmp = queue.remove();				visit(tmp);				if(!visited[tmp]){					if(graph.areAdjacent(tmp, t)){						//Print the path						found = true;					}else{						VertexIterator tmp2 = graph.adjacentVertices(tmp);						while(tmp2.hasNext()){							queue.add(tmp2.next());						}					}				}			}else{				System.err.println("No path from : " + f + "to " +t);				nopath = true;			}		}	}