Introduce base adjacencyList struct and reorg code around it.