creating objects to simulate a graph and applying methods to traverse them