Adjacency List
In the adjacency list representation of a graph, each node has a list of nodes that are adjacent to it, i.e. connected by an edge. A linked list is a natural representation.
| 1 | (5 2) |
| 2 | (3 5 1) |
| 3 | (4 2) |
| 4 | (6 3 5) |
| 5 | (4 2 1) |
| 6 | (4) |
This graph is undirected, so each link is represented twice.
The storage required is O(|V| + |E|). This is a good representation if the graph is sparse, i.e. each node is not linked to many others.