graph refactoring