reading graph from list of edges