Changing graph methods to take pointers as argument