Overview
There are two standard ways of representing graphs in memory: adjacency-list representations and adjacency-matrix representations.
Adjacency-List
Let be a graph. An adjacency-list representation of has an array of size . Given , the index corresponding to contains a linked list containing all adjacent vertices.
Adjacency-Matrix
Let be a graph. An adjacency-matrix representation of is a matrix such that
Bibliography
- Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).