Guest User

Untitled

a guest
Jan 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. private void breadthFirstSearch(UndirectedGraph g, int a, int b, boolean[] visited, VertexAction action){
  2. if(visited[a]){
  3. return;
  4. }
  5. LinkedList<Integer> queue = new LinkedList();
  6. while(!queue.isEmpty()){
  7. int hej = queue.getFirst();
  8. VertexIterator vi = g.adjacentVertices(hej);
  9. while(vi.hasNext()){
  10. if(!visited[a]){
  11. if(a == b)
  12. return;
  13. queue.add(a);
  14. queue.poll();
  15. }
  16. }
  17. }
Add Comment
Please, Sign In to add comment