Graphs
Model relationships as nodes and edges, then traverse with BFS (shortest path) or DFS (all paths, connectivity).
- • Connected components
- • Shortest path
- • Dependency ordering
- • Cycle detection
- • Minimum spanning tree
- • Simple linear data
- • No relationships between elements
- • Forgetting visited set
- • Confusing directed vs undirected
- • Not handling disconnected components
Key Invariant
BFS finds shortest unweighted paths; DFS explores all paths — always track visited nodes