Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void breadthFirstSearch(UndirectedGraph g, int a, int b, boolean[] visited, VertexAction action){
- if(visited[a]){
- return;
- }
- LinkedList<Integer> queue = new LinkedList();
- while(!queue.isEmpty()){
- int hej = queue.getFirst();
- VertexIterator vi = g.adjacentVertices(hej);
- while(vi.hasNext()){
- if(!visited[a]){
- if(a == b)
- return;
- queue.add(a);
- queue.poll();
- }
- }
- }
Add Comment
Please, Sign In to add comment