Added more tests before refactoring Graph class.
Refactored Graph.

Added code to keep an explicit track of the nodes.