A graph is a set of vertices connected by edges. The two standard representations are the adjacency list (each vertex stores its neighbors) and the adjacency matrix (a V×V grid of booleans). The choice depends on graph density.
The two forms
text
Graph: 0 - 1
| |
2 - 3
Adjacency list: Adjacency matrix:
0: [1, 2] 0 1 2 3
1: [0, 3] 0 [0 1 1 0]
2: [0, 3] 1 [1 0 0 1]
3: [1, 2] 2 [1 0 0 1]
3 [0 1 1 0]
