implementation of graph