implements Storage, Stack and Queue objects
traverses a graph g depth-first or breadth-first, depending on what the methods .get() and .put() of storage do