~/ learn/ comp-372/ cards/ Graph representations: lists vs matrices
1 of 6

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.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/6d5f35e3-d1af-4fe7-892b-7485e9db3edc/flashcard utf-8 LF