clean up nodes in graph destruction

This makes for easier memory management, as the graph can track the node
objects which are allocated to it.