Graph Theory37 sections · 1633 units
Open in Course

Matrix - The Problem

Why we rarely use it

The Adjacency Matrix is fast for checking edges, but it has a huge flaw: Memory. It requires N2N^2 space.

If N=1000N = 1000, you need 11 million cells. If N=100000N = 100000, you need 1010 billion cells. That exceeds typical memory limits. Most competitive programming graphs have NN up to 10510^5 or 10610^6 but only MM up to 10610^6 edges. Storing N2N^2 cells when you only have MM connections is wasteful. You need something more efficient for sparse graphs.