Module 26 ยท Data Structures & Problem-Solving โ Lesson 5 of 7 ยท ~11 min
Graphs: BFS & DFS
Nodes connected by edges
A graph is nodes joined by edges โ more general than a tree because there's no single root and cycles are allowed. Model it as an adjacency map: a dict from each node to the list of its neighbors.
PawWalk example: neighborhoods connected by walkable routes. graph['Downtown'] is the list of neighborhoods you can reach directly on foot from Downtown.