Graph encoding schemes:
Adjacency list: Below we represent a graph of 6 nodes with an adjacency list.
1 → 2 → 4/ 2 → 5/ 3 → 6 → 5/ 4 → 2/ 5 → 4/ 6 → 6/
Adjacency matrix: Below we reperesent the same graph of 6 nodes with an adjacency matrix.
1 2 3 4 5 6 1 0 1 0 1 0 0 2 0 0 0 0 1 0 3 0 0 0 0 1 1 4 0 1 0 0 0 0 5 0 0 0 1 0 0 6 0 0 0 0 0 1
- Obviously the list saves space and the matrix saves access time.