Refactor GraphSerializer

The code now prints out the graph in an unordered fashion (as was
implemented in the previous commit). Remnants from the ordered serialize
method remained. These were removed and the logic simplified.