adjacency list representation of random.cpp