Mental Model
Graphs can be stored in two main ways: adjacency lists save neighbors only, adjacency matrices save all connections in a grid.
Analogy: Think of a city map: adjacency list is like a list of direct roads from each city, adjacency matrix is like a big table showing if any road exists between every pair of cities.
Adjacency List:
City 0: 1 -> 3 -> null
City 1: 0 -> 2 -> null
City 2: 1 -> null
City 3: 0 -> null
Adjacency Matrix:
0 1 2 3
0 [ 0 1 0 1 ]
1 [ 1 0 1 0 ]
2 [ 0 1 0 0 ]
3 [ 1 0 0 0 ]