Testing the Undirected Graph

The string produced by graph.toString():

1 -> 2 -> 5
2 -> 1 -> 5 -> 4 -> 3
3 -> 2 -> 4
4 -> 2 -> 3 -> 5
5 -> 1 -> 2 -> 4