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.