refactoring Graph to support both uni/di-graph