add reduce method for AdjList