Graph Theory37 sections · 1633 units
Open in Course

The Representation Problem

How to tell the computer?

You know what a graph looks like on paper: circles and lines. But how do you tell a C++ program about it? A computer only understands numbers and arrays.

You need a data structure that answers questions like: "Is there an edge between uu and vv?" or "What are all neighbors of node uu?" Two main approaches exist: the Adjacency Matrix and the Adjacency List. Each has trade-offs in memory, speed, and simplicity. Choosing the right one depends on your graph's density.