Refactor read graph method.