reimplemented graphs with adjacency list