Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. int BFS(G: (V, E), source: int, destination: int):
  2. d = int[|V|]
  3. fill(d, ∞)
  4. d[source] = 0
  5. Q = ∅
  6. Q.push(source)
  7. while Q ≠∅
  8. u = Q.pop()
  9. for vu in E
  10. if d[v] == ∞
  11. d[v] = d[u] + 1
  12. Q.push(v)
  13. return d[destination]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement