Use vectors instead of lists for checking adjacency