Separates graph creation code.

Puts graph creation code in separate file.