complexitygraphs
Adjacency lists or a matrix?
Anonymous
An adjacency list stores each vertex's neighbors, so its space grows with the vertices and edges. A matrix uses space quadratic in the vertex count, but checking whether an edge exists takes O(1). Lists are often a good fit for sparse graphs; a matrix can suit dense graphs or frequent edge checks.
0