Added additional functionality to graph and provided more explanatory comments.