implemented some methods for the graph class