In an adjacency list, the neighbors of a vertex are the elements in the associated list for that vertex.
# Assuming g is an instance of GraphAdjacencyList
def get_neighbors(graph, vertex):
return graph.graph[vertex]
# Example Usage
neighbors = get_neighbors(g, 1)
print(neighbors) # Output: [0, 2]