updated graph implementation