Refactoring code to API functions - addEdge, addNode - testing and fixing issues with addToGraph