Commit before rearranging code.
Moved graph stuff to its own file; it now kind of works.