Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int BFS(G: (V, E), source: int, destination: int):
- d = int[|V|]
- fill(d, ∞)
- d[source] = 0
- Q = ∅
- Q.push(source)
- while Q ≠∅
- u = Q.pop()
- for vu in E
- if d[v] == ∞
- d[v] = d[u] + 1
- Q.push(v)
- return d[destination]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement