finished some methods of graph class, added helper methods to reduce
code re-use.