Update 57: Updating the graph data structure.

I have added an invariant testing function and a stack-based
backtracking routine for restoring a graph by popping and undoing
small changes.