Type the adjacency-list build for one directed edge (u,v)
Type the adjacency-list build for one directed edge (u,v)
Answer
adj[u].append(v)
A directed edge adds v to u’s list only. An undirected edge would also do adj[v].append(u). This is the one-line core of every graph build.