VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 11: Graphs

Lesson 11.6 of 16 in this module Unrolled Pro

Course Schedule

Can all courses be finished, given prerequisite pairs? Exactly when the prerequisite graph has no cycle. From repeatedly scanning for a course with no unfinished prerequisites (O(V · E)), to Kahn's algorithm, which keeps in-degree counts and a queue of ready courses (O(V + E)), and DFS with three colours that finds a back edge. Then reporting the actual cycle, validating a pipeline DAG before it runs, and checking that adding one dependency keeps a graph acyclic.

about 10 min 3 Python examples 2 quick checks

Problem. There are n courses labelled 0 to n − 1, and a list of pairs [a, b] meaning "to take a you must first take b". Return whether it's possible to finish all courses.

text
n = 2, prerequisites = [[1, 0]]           →   True    (take 0, then 1)
n = 2, prerequisites = [[1, 0], [0, 1]]   →   False   (each requires the other)

Draw an edge b → a for every pair ("b comes before a"). All courses can be finished exactly when this directed graph has no cycle: a cycle is a set of courses that each wait for another in the set, so none can ever start.

ML context. Every pipeline orchestrator (Airflow, Kubeflow, Dagster, a build system, a feature store's derived features) must check that its task graph is a DAG before running it, and report the cycle if it isn't. Autograd graphs are DAGs by construction; a model config that wires a layer's output into an earlier layer creates a cycle that a static graph compiler must reject (Changes A and B).


1. Step 1: Clarify

That's the preview. Modules 00–01 are free; this lesson is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "Course Schedule"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee