refactor EdgeGraph to be more reusable