Overview
0-1 BFS uses a deque instead of a heap: relaxing a zero-cost edge pushes the neighbor to the front, while relaxing a one-cost edge pushes it to the back.
Finds shortest paths in graphs whose edge weights are only 0 or 1.
Compact metadata for implementation and discovery.
0-1 BFS uses a deque instead of a heap: relaxing a zero-cost edge pushes the neighbor to the front, while relaxing a one-cost edge pushes it to the back.
Quick facts
Runtime and memory behavior at a glance.
Best
O(V + E)
Average
O(V + E)
Worst
O(V + E)
Space
O(V)
Show using a deque to process zero-cost edges before one-cost edges on a small shortest paths with binary weights example.
0-1 BFS is a specialized shortest-path algorithm, not a general replacement for Dijkstra.
What each reference supports for this entry.
Textbook support for 0-1 BFS invariants, recurrences, relaxation rules, or asymptotic analysis.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Pathfinding · Core
0-1 BFS and Visibility Graph Roadmap both relate to shortest paths with binary weights, but use different structures or assumptions.
Compare with this0-1 BFS and Visibility Graph Roadmap both relate to shortest paths with binary weights, but use different structures or assumptions.
0-1 BFS and Dial's Algorithm both relate to shortest paths with binary weights, but use different structures or assumptions.
0-1 BFS and Eppstein K Shortest Paths both relate to shortest paths with binary weights, but use different structures or assumptions.