Adjacency List

Discover how graphs can be represented in code using adjacency lists.

The second option to represent graph edges in code is the adjacency list.

Adjacency list

In this data structure, we store a list of each node’s neighbors.

Let’s look at our example graph again. We use the same integer encoding of nodes that we did for the adjacency matrix.

Get hands-on with 1400+ tech skills courses.