There are usually two standard ways to represent a graph G = (V, E) in a computer program:
- As a collection of adjacency lists
- As an adjacency matrix
You can use either way to represent both directed and undirected graphs. We'll start by looking at the adjacency list representation.