refactor for graph.hpp