...

/

Comparison of Graph Representations

Comparison of Graph Representations

Learn how adjacency matrices and adjacency lists compare.

After studying both adjacency matrices and adjacency lists, let’s see how they compare for common operations that we’ll perform in graph algorithms.

In most applications of graph algorithms, the set of nodes VV is constant. No nodes are added or removed over time. We can therefore focus on operations that work on the edge set EE.

Memory usage

The adjacency matrix stores at least one bit for every ordered pair of nodes (u,v)(u, v). Since there are exactly (V2V)(|V|^2 - |V|) such pairs, the memory footprint is O(V2)\mathcal{O}(|V|^2) ...