O'Reilly logo
  • You Wang thinks this is interesting:

A recurring theme when working with graphs is that the best representation depends on what you need to do with your graph. For example, using adjacency lists (or arrays) keeps the overhead low and lets you efficiently iterate over N(v) for any node v. However, checking whether u and v are neighbors is linear in the minimum of their degrees, which can be problematic if the graph is dense, that is, if it has many edges. In these cases, adjacency sets may be the way to go.

From

Cover of Python Algorithms: Mastering Basic Algorithms in the Python Language, Second Edition

Note

adjacency set is better for checking neighborship, list is better for iteration