Skip to main content

One doc tagged with "graph"

View all tags

Graphs and traversal — following the connections

This chapter introduces graph vocabulary and two representations, then explains when to use breadth-first vs. depth-first search. It covers why BFS produces shortest paths without weights, why visited sets are needed, ordering by dependency and detecting cycles with topological sort, and the trick of treating states as vertices.