refactoring of merge graph