%3C/text%3E%3C/svg%3E">
💻
💻 Tech & IT

Graph Memory Calculator (adjacency matrix vs list)

Results update as you type.

Your numbers

Understanding the graph memory calculator — concept and principle

A graph can be stored as an adjacency matrix (a V × V grid that marks every possible edge) or as adjacency lists (each vertex keeps only the neighbors it actually has). This calculator estimates the memory of both layouts and the graph's density, so you can choose a representation before loading a large network, road map or social graph.

Adjacency matrix versus adjacency list memoryA 100,000-vertex matrix needs 10¹⁰ bits (1.25 GB) while a list for 1,000,000 edges needs 8.4 MB; the small square is drawn to the same area scale.Matrix vs list for 100,000 verticesMatrix: V × V cells10¹⁰ bits = 1.25 GBlist at true size037142059⋮List: (V + 2E) × 4 B= 8.4 MBList is ≈ 149× smalleronly 0.02% of possible edges exist
For a sparse graph (density 0.02%) the adjacency list needs about 1/149 of the matrix memory.

How it is calculated

The principle

A matrix reserves a cell for every pair of vertices, whether or not they are connected, so its size grows with V² and does not depend on E. Adjacency lists grow with V + E. The compact form counted here is like compressed sparse row (CSR): an offsets array with one entry per vertex and a single neighbor array. Real-world graphs are usually sparse; each vertex has a handful to a few thousand neighbors, while V − 1 neighbors are possible, so lists are typically far smaller. A matrix wins only when the graph is dense or when you need constant-time "is u connected to v?" checks.

Worked example

  1. Inputs: V = 100,000, E = 1,000,000, 4 bytes per entry.
  2. Matrix: 100,000² = 10¹⁰ bits ÷ 8 = 1.25 × 10⁹ bytes = 1.25 GB.
  3. List: (100,000 + 2 × 1,000,000) × 4 = 8,400,000 bytes = 8.4 MB.
  4. Density: 1,000,000 ÷ (100,000 × 99,999 ÷ 2) = 1,000,000 ÷ 4,999,950,000 ≈ 0.02%.

The list is about 150 times smaller, even though the matrix uses only one bit per cell.

How Adjacency matrix (GB, 1 bit) changes with VerticesHow Adjacency matrix changes with Vertic…01234525,00050,00075,000100,000125,000150,000200,000Example: 1.25Vertices
Each point is the calculator re-run with only “Vertices” changed; the gold point is the default example. Change the inputs above and this chart follows your numbers.
VerticesAdjacency matrix (GB, 1 bit)
25,0000.078125
50,0000.3125
75,0000.703125
100,0001.25
125,0001.953125
150,0002.8125
200,0005

How to read the result

Density near 0% means a sparse graph: use lists. Bit-matrix and list sizes are equal around 2E × 32 ≈ V² for 4-byte entries, i.e. at a density of roughly 3%; above that, and especially above 10–20%, a matrix becomes competitive. Average degree 2E ÷ V (here 20) is another quick check.

Common mistakes

Keep in mind: Real libraries add pointers, object headers and allocator overhead, so linked-list or hash-map adjacency structures can take several times the compact estimate.

Frequently asked questions

When should I use an adjacency matrix?

For small or dense graphs, or algorithms such as Floyd–Warshall that touch every pair anyway.

Why GB for one and MB for the other?

The units follow typical sizes; both use decimal units (1 GB = 10⁹ bytes, 1 MB = 10⁶ bytes).

How do I store a directed graph's incoming edges?

Keep a second CSR for the reverse graph, which doubles the list memory.

Sources: T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein, Introduction to Algorithms, MIT Press (representations of graphs) · R. Sedgewick, K. Wayne, Algorithms, 4th ed., Addison-Wesley (graph representations)

Checked 8 Nov 2026. Standard formulas and RFC/IEEE definitions, computed locally in your browser — nothing you type is sent anywhere.

💻 All tech & IT tools →🌍 Calculators by country →