Refactor common graph code

* Renames Graph.scala to Producer.scala (duh?)
* Adds a graph package in core.
* Move the pure graph functions into the graph package.