Moved graph functions to graph.js