Refactor IdGraphStrategy to extract reusable function.