refactor factories for Node and Relation