Encapsulated graph code in object (eventually), and altered addToGraph so only nodes not yet added can be... added.