Skip to Main Content
Graph Algorithms the Fun Way
book

Graph Algorithms the Fun Way

by Jeremy Kubica
November 2024
Intermediate to advanced content levelIntermediate to advanced
416 pages
11h 11m
English
No Starch Press
Content preview from Graph Algorithms the Fun Way

5 BREADTH-FIRST SEARCH

Breadth-first search is an alternative approach for exploring graphs that progresses like a wave from a starting node. Whereas depth-first search prioritizes recently discovered nodes, breadth-first search prioritizes exploring nodes discovered earlier in the search. This simple change in prioritization leads to radically different behavior of the search algorithm, along with a variety of useful properties.

The key idea behind breadth-first search is that it explores nodes using a first-in, first-out ordering, such as that provided by a queue. Each time the search encounters a previously unseen node, it places that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Grokking Algorithms, Second Edition

Grokking Algorithms, Second Edition

Aditya Bhargava
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
Algorithms: 24-part Lecture Series

Algorithms: 24-part Lecture Series

Robert Sedgewick, Kevin Wayne

Publisher Resources

ISBN: 9781098182519Errata Page