Ordering What Depends on What
In short: a topological order lists every job so each one's needs come before it. Kahn's algorithm builds one by counting, for each job, how many needs it's still waiting on — its in-degree — and emitting any job whose count reaches zero. Emitting a job lowers its dependants' counts, which can make more jobs ready, so the queue keeps feeding itself until it runs dry. If jobs are left over when it does, they wait on each other in a cycle, and no order exists.

Welcome to Meridian, a city logistics network. It has depots, roads, one-way streets, vans, drivers and jobs, and over the next few sections you will build the software that runs it. This section builds Meridian's model of the city: what the network is made of, which parts hold it together, and where it is fragile. Routing parcels through it comes later. First, the network has to exist.
Meridian is opening a depot in the north of the city, and the build-out is a list of jobs with strings attached. The site has to be surveyed before it can be graded. Grading also needs a permit. Paving waits for grading, and the traffic signals wait for both the paving and the permit. Five jobs, five "this before that" rules, and one question: in what order can the crews work?
Needs are directed edges
Draw each job as a node and each rule [before, after] as an arrow from before
to after. The result is a directed graph, and it is the same adjacency-list
shape you used for the follow graph in the graphs section, with one extra number
per node: how many arrows point into it. That count is the node's
in-degree, and here it means "how many jobs am I still waiting for?"
An order that puts every before ahead of its after is a topological order.
It is not unique: survey and permit have no needs at all, so either can go first.
It can also fail to exist, as you'll see shortly. Checking whether a proposed order
is valid is easy: every rule's before must sit at an earlier position.
needs = [["survey", "grade"], ["permit", "grade"], ["grade", "pave"]]
order = ["permit", "grade", "survey", "pave"]
position = {task: i for i, task in enumerate(order)}
print(all(position[a] < position[b] for a, b in needs))