Fix segmentation fault when accessing the adjacent list