build the adjacency list