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

A more flexible approach, allowing us to use arbitrary, hashable, node labels, is to use a dict as this main structure.15 Listing 2-4 shows what a dict containing adjacency sets would look like. Note that nodes are now represented by characters.


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


Using a dict as main structure is much more intuitive and readable.