Moved js code to graph.js and added solutions (previously buggy)