liveBook · Manning

Adjacency list

As explained in Advanced Algorithms and Data Structures

An adjacency list is a graph representation that stores, for each vertex, a list of its incident or outgoing edges and neighboring vertices.

When a graph stores every edge in one list, finding a vertex’s neighbors requires scanning that list. An adjacency list instead maps each vertex to its incident or outgoing edges, making graph operations depend on local neighborhoods. section 14.1.1

A directed graph

A compact representation maps 1 to edges leading to 2 and 3, maps 2 to an edge leading to 4, and gives 3 and 4 empty lists. Each entry can store an edge object containing its source, destination, weight, and label. section 14.1.1 section 14.1.3

A practical graph implementation typically provides:

  • A vertex collection plus a hash-table mapping each vertex to its edge list. section 14.1.3
  • Vertex insertion that initializes an empty list, and edge insertion that validates endpoints and replaces an existing edge when necessary. section 14.1.3
  • Space usage of O(|E| + |V|); listing outgoing or incoming edges costs O(|E|), while a dense graph may favor an adjacency matrix. section 14.6
1 -> [(1,2), (1,3)]
2 -> [(2,4)]
3 -> []
4 -> []

Browse a concrete adjacency-list mapping before comparing it with the corresponding matrix representation. section 14.1.1

How Advanced Algorithms and Data Structures covers it

How deep it goes
Explains the mapping, class structure, operations, and complexity trade-offs, stopping short of full algorithm implementations.
Examples
Uses a vertex-to-edge dictionary, a four-vertex listing, and a Graph class with weighted, labeled Edge objects.
What it assumes
Assumes graph vertices and edges, while defining how those elements are organized for operations.
What you can do after
Build it from scratch using vertex collections, edge lists, validation, and adjacency-list operations.
How it connects
Connects graph representations with adjacency matrices, BFS, DFS, Dijkstra’s algorithm, and A*.

Also explained in

Compare how 5 books explain adjacency list →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.