Representing a graph
A graph of $V$ vertices and $E$ edges can be stored as adjacency lists in $O(V + E)$ space, or as an adjacency matrix in $O(V^2)$ that answers "is there an edge?" in $O(1)$, and sparse graphs, the common kind, want lists.
A graph of $V$ vertices and $E$ edges can be stored as adjacency lists in $O(V + E)$ space, or as an adjacency matrix in $O(V^2)$ that answers "is there an edge?" in $O(1)$, and sparse graphs, the common kind, want lists.