Graphs as data structures in Python