Refactor Graph into its own module.